computeStream<Q, R> method
- @experimental
- @override
- IsolateStream<
Q, R> callback, - Q message, {
- String? debugLabel,
override
A computation function that returns a Stream of responses from the long lived isolate.
Very similar to the compute function, but instead of returning a Future, a Stream is returned to allow for a response in multiple parts. Every stream event will be sent individually through from the isolate.
Implementation
@experimental
@override
Stream<R> computeStream<Q, R>(
IsolateStream<Q, R> callback,
Q message, {
String? debugLabel,
}) {
// TODO(lohnn): Implement onListen?
// TODO(lohnn): Implement onPause?
// TODO(lohnn): Implement onResume?
final streamController = StreamController<R>();
addIsolateCall((flow) {
final isolateConfiguration = StreamIsolateConfiguration(
callback,
message,
debugLabel,
flow.id,
);
return StreamBackpressureConfiguration(
streamController,
isolateConfiguration,
);
});
return streamController.stream;
}