onProgress method
A stream of progress notifications for a given request
.
The request
must contain a ProgressToken in its metadata (at
request.meta.progressToken
), otherwise an ArgumentError will be
thrown.
The returned stream is a "broadcast" stream, so events are not buffered and previous events will not be re-played when you subscribe.
Implementation
Stream<ProgressNotification> onProgress(Request request) {
final token = request.meta?.progressToken;
if (token == null) {
throw ArgumentError.value(
null,
'request.meta.progressToken',
'A progress token is required in order to track progress for a request',
);
}
return (_progressControllers[token] ??=
StreamController<ProgressNotification>.broadcast())
.stream;
}