Last active
August 6, 2019 02:03
-
-
Save lmzach09/e4900dc76f5e39bc29b26a6939284ce6 to your computer and use it in GitHub Desktop.
This is a function that a Dart Isolate can execute. It will listen for messages from the main thread and also send messages to the main thread.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void myIsolate(SendPort isolateToMainStream) { | |
ReceivePort mainToIsolateStream = ReceivePort(); | |
isolateToMainStream.send(mainToIsolateStream.sendPort); | |
mainToIsolateStream.listen((data) { | |
print('[mainToIsolateStream] $data'); | |
}); | |
isolateToMainStream.send('This is from myIsolate()'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment