example of using _createMoorIsolate #1257
-
from https://moor.simonbinder.eu/docs/advanced-features/isolates/, from https://moor.simonbinder.eu/docs/advanced-features/isolates/#initialization-on-the-main-thread, in my main method, i started to put the line below there to set a global Database db variable for me to use this isolate db, but i need to see how to use this with _createMoorIsolate. as i noticed _connectAsync from that doc returns a Future |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 15 replies
-
void main() {
db = Database.connect(DatabaseConnection.delayed(_createMoorIsolate()));
// ...
}
I don't see a contradiction here :D If you want to turn a |
Beta Was this translation helpful? Give feedback.
DatabaseConnection.delayed
is the way to go. It takes a future as an argument and returns a connection that is ready once the future completes.So you should be able to just setup the database like this:
I don't see a contradiction here :D If you want to turn a
Future<DatabaseConnection>
into aDatabaseConnection
, useDatabaseConnection.delayed
.If that doesn't work for you please let me know.