Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active May 3, 2019 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/e7b368181a0a2ea604f98bd3c66f8342 to your computer and use it in GitHub Desktop.
Save hlung/e7b368181a0a2ea604f98bd3c66f8342 to your computer and use it in GitHub Desktop.
class FeedViewController: BaseViewController {
//...
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
setupBindings()
sessionDidUpdate(appCoordinator.session)
}
func sessionDidUpdate(_ session: Session) {
// fetcher is responsible for providing the data. more on this later.
// Here we clear data because user information has changed, so the data in fetcher is probably invalid.
fetcher.clearData()
fetcher.reload.onNext(parameter) // parameter is the information used to setup the fetcher.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
reloadFromCache()
}
func reload() {
fetcher.reload.onNext(parameter)
}
func reloadFromCache() {
tableView.reloadData()
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment