I am new to RxSwift and here I would like to ask a question about where should the DisposeBag be.
My case is, I have retrieve a list of items being displayed in a tableview, and each of them will have its own flag to indicate if it is selected.
So I am not just binding the result list to the tableview. I need to have some logic which editing the list on local while user navigate via the tableview.
I have created an instance Variable([Item])
in the ViewModel
but if I place the logic in the ViewModel
a DisposeBag
is needed.
After having some googling, most of the examples of MVVM+RxSwift which have instances of Variable
place the DisposeBag
in ViewModel
but some say it should only be placed in ViewController
. Is that true? How can I listen the Observable
in ViewModel
so that my business logic can be placed in ViewModel
?