I'm looking for a coding pattern that comfortably solves the following problem: This is a paradigm I find myself having to use a lot in my development. After the user opens any UI likely the following is happening:
- Load data from local storage
- Update UI with local data
- Load data from remote
- Store remote data to local storage
- Update UI with remote data
A simple example would be loading a Twitter timeline for example. The app will present to the user what it has, updates from remote in the background and then updates the UI if it found more recent tweets.
Ideally, each step would run async and be cancelable at any time. I've been using a mix of Futures/Promises and Callbacks so far but I find myself writing a lot of glue code...
Any suggestions would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire