Use of Isolates #3268
Replies: 3 comments 4 replies
-
What is You also don't have to combine |
Beta Was this translation helpful? Give feedback.
-
Yes sorry for the isolateGetIt, it's a bad replacement for copy-paste, I had tried to create a getIt specific to the isolate.
But the problem is that when I run the task via the WorkManager, I get this error when I want to access the database ...
Ex methods call : TEST 1 : Exception
TEST 2 : Exception
CREATE : Exception
|
Beta Was this translation helpful? Give feedback.
-
No worries, actually I hadn't put the code of the callbackDispatcher of my WorkManager:
The token is therefore created in the WorkManager and not passed to the task |
Beta Was this translation helpful? Give feedback.
-
Hello,
I apologize for bothering you but I must be missing something, I can't figure out how to properly use Isolates with Drift.
To make it short:
I need to access my DB directly and sometimes via Isolates from the WorkManager.
Before seeing your section on Isolates, sometimes it worked with my basic implementation, sometimes I had the error message
Exception: No platform channel handler registered for background isolate.
Then I came across your doc.
I can't do all the processing of my isolate from a DriftIsolate.spawn(), or the computeWithDatabase, I need to have access to other classes and all the logic already built (then, I use 2 different DBs within my app).
Also, I use getIt dependency injection.
I tried to do this:
Then, at the beginning of my isolate, I do:
But already, I have a warning that is displayed when my isolate opens and I call getIt.init() to retrieve my DB.
WARNING (drift): It looks like you've created the database class SynchroErrorsDatabase multiple times. When these two databases use the same QueryExecutor, race conditions will occur and might corrupt the database.
I feel like I'm not doing things right but I don't know where, can you help me please?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions