Open p-nicolaou opened 5 years ago
I’m my case, I ended up creating Workers that are “global” to the app (available to all of the scenes). They do all of the data accessing (whether local DB or API calls). In fact, the way I solved this is that I setup my workers to allow chaining. This allowed me to call the Database worker, and have the Database worker call an API worker if the data doesn’t exist in the Database/Cache…I even went a step further to pass two blocks instead of just one, so that the initial/cached data could be returned immediately by the database/cache worker, while the database/cache worker could (in the background) call the API worker to load the remote data, pass it back to the database/cache worker who would store the data in the cache/DB and then return it in the second block to the scene interactor. On Jan 4, 2019, 7:34 AM -0600, p-nicolaou notifications@github.com, wrote:
I would like to ask what's the best practise (if any) in case we have a scene that's fetching something from the network and after that, we want to store these data locally (core data). In addition, if multiple scenes required to have the same (network->core data) can we have a universal (re-usable) worker(s)? I read about multiple stores in the TDD approach https://clean-swift.com/clean-swift-tdd-part-3-worker/ as well as multiple workers under the same interacor, https://clean-swift.com/role-of-the-interactor-and-its-workers/ but I am a bit confused regarding what approach should follow here — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hello @ehlersd. Would be nice to check out this approach. Do you have a sample project somewhere?
I would like to ask what's the best practise (if any) in case we have a scene that's fetching something from the network and after that, we want to store these data locally (core data). In addition, if multiple scenes required to have the same (network->core data) can we have a universal (re-usable) worker(s)? I read about multiple stores in the TDD approach https://clean-swift.com/clean-swift-tdd-part-3-worker/ as well as multiple workers under the same interacor, https://clean-swift.com/role-of-the-interactor-and-its-workers/ but I am a bit confused regarding what approach should follow here