Last active
May 3, 2019 11:53
-
-
Save hlung/e7b368181a0a2ea604f98bd3c66f8342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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