How to achieve reactive behavior (auto-update stream) with background fetching #1057
Replies: 1 comment
-
In real-time? If so, you could use the moor isolates library. It allows you to synchronize stream-queries between isolates. |
Beta Was this translation helpful? Give feedback.
-
Currently I have all my queries being called on a singleton instance given by getIt like this:
getIt.registerSingleton<AppDb>(AppDb());
Now I want to accomplish a periodic background fetch every x minutes, and upsert data on the database.
How should I approach this using a library like WorkManager (https://github.com/fluttercommunity/flutter_workmanager) or background_fetch (https://github.com/transistorsoft/flutter_background_fetch) with moor?
I have read the documentation but I couldn't see any example of this.
I fear I might lock the database since different isolates may call two different instances.
I want to be able to see the changes that might occur on the background fetch.
Beta Was this translation helpful? Give feedback.
All reactions