RxSwift is a powerful framework and, as always, with power comes responsibility. In RxSwift the memory is usually managed through an object called a
For instance, every time we subscribe to an
Observable, RxSwift makes sure the subscription is kept in memory until either a
.error event is received or the subscription is being garbage collected by the
It is fairly easy to make a mistake and to add the subscription to a wrong
DisposeBag. For example, to add it to the controller’s bag instead of the cell’s. Mistakes happen and to catch them early it is a good idea to add a resource counting mechanism to each view controller. The mechanism will make sure resources allocated during the lifetime of the view controller are released and if no, will output an error.
Infinum provides a default implementation of such a mechanism.
Subscribe to The infinite monkey theorem
Get the latest posts delivered right to your inbox