onSticky<T extends Object?> method
Subscribes to sticky + future events of type T.
Implementation
Stream<T> onSticky<T extends Object?>() {
return Stream<T>.multi((sink) {
final subscription = on<T>().listen(
sink.add,
onError: sink.addError,
onDone: sink.close,
);
// Capture the cache at listen time and buffer before invoking user callbacks.
if (_lastByType.containsKey(T)) sink.add(_lastByType[T] as T);
sink.onCancel = subscription.cancel;
sink.onPause = subscription.pause;
sink.onResume = subscription.resume;
}, isBroadcast: true);
}