I am learning Dart:
main() async
{
ReceivePort receivePort = ReceivePort();
Isolate.spawn(echo, receivePort.sendPort);
// await for(var msg in receivePort)
// {
// print(msg);
// }
receivePort.listen((msg) { print(msg);} );
}
echo(SendPort sendPort) async
{
ReceivePort receivePort = ReceivePort();
sendPort.send("message");
}
I can't understand when it's better to use await for(var msg in receivePort)
and when receivePort.listen()
? By the first look it's doing same. Or not?