I am using RxSwift for tableview. I need to reload my table each time after getting data from api but I'm failed to do this. I couldn't find any solution for that. Can anybody help?
I have an array of places obtain from response of an Api.I have used this code in view did load, but its is not being called when array is updated.
I have found the issue. My array was not being getting updated correctly. I did the following changes.
Declare
dataSource
variable of ModelClass:Bind it with the table view right now it is empty:
Then store my updated array in it that contains the searchPlaces:
Now each time when value of dataSource will be changed, table view will be reloaded.
Avoid using "Variable" because of this concept will be deprecated from RxSwift but official migration path hasn't been decided yet.
REF: https://github.com/ReactiveX/RxSwift/issues/1501
Hence, recommend using RxCocoa.BehaviorRelay instead.
Bind to tableView
after fetch data:
Hope this can help :)
Let
Whenever you hit your API, put your fetched results in
self.array.value
and it will automatically gets updated.