I have started using isolates and returned a value from my isolate as if it was a function.
Then I wanted to change the code to return stream, instead of future.
From this
compute<List<String>, List<String>>(
(params) async { ... return ...;
I wanted to change to this
compute<List<String>, Stream<String>>(
(params) async* { ... yield ...;
But I get the error:
The argument type 'Stream<FutureOr<Stream>> Function(List)' can't be assigned to the parameter type 'FutureOr<Stream> Function(List)'. (Documentation)
If I understand correctly we can transfer data back "as stream" by opening ports and sending data through it.
Wouldn't it be better if the syntax will stay the same as "Stream function" and the implementation will do that for us?.
When opening ports you need to handle some extra staff like checking if the port is free and changing to a different port number if it doesn't.
Some extra explanation why opening a port is not needed when returning a single value and is needed when returning a stream will be welcome as well.
Should we ask for Dart team to make the change for isolates to support stream as well?.
Related to dart vm send back stream from isolate