i created an observable for an api call and bind to a tableview. Now i am unclear how to call the same api once again? so as to do a refresh - say on an button click?. The following is my sample code.
Please let me know your thoughts it will be helpfull
var items : Observable<[String]>?
func viewDidLoad(){
items = fetchAllAnswers()
items.bindTo(....).addDisposableTo(bag)
}
func fetchAllAnswers() -> Observable<[String]>{
let api = Observable.create { (obsever: AnyObserver<[String]>) -> Disposable in
let answers = API.allAnswers()
obsever.onNext(answers)
obsever.onCompleted()
return AnonymousDisposable{
print("api dispose called")
}
}
return api
}
func onClickRefresh()
{
// how to call api here again?
// let items = fetchAllAnswers()
// items.bindTo(....).addDisposableTo(bag)
}