ReactiveSink<T> class

A special kind of Sink with its own single stream listener that handles the event data.

An event stream can be transformed by Transform callback function passed at the constructor.

Example.

var i = 0;

final sink = ReactiveSink<int>((event) {
  i = i + event;
}, transform: (stream) => stream.map((e) => e * 2), disposer: null);

sink(1); // Shorthand notation of "sink.add(1);".

Future.microtask(() {
  print(i); // prints 2.
});

To save CPU and memory usage, the stream is lazily listened when a first data is added to the sink, or HandleSubscription is passed to its constructor.

Disposing its resource, or delegating to other ReactiveResource.

ReactiveSink is a kind of ReactiveResource, which provides resource disposing action by dispose sink. dispose action can be delegated to other ReactiveResource, typically a ReactiveComponent. See ReactiveComponent for more explanation about delegating dispose.

Implemented types
Implementers

Constructors

ReactiveSink(OnData<T> onData, {Transform<T> transform, @required ResourceDisposer disposer, VoidCallback onDispose, OnError onError, bool cancelOnError, VoidCallback onListen, VoidCallback onPause, VoidCallback onResume, VoidCallback onCancel, HandleSubscription<T> handleSubscription})
Constructs a ReactiveSink with its event stream handler.
factory

Properties

dispose → VoidSink
A VoidSink to dispose of the resources.
read-only
disposed Stream<void>
A stream to notify the resource has been disposed of.
read-only
eventStreamSubscription StreamSubscription<T>
For only testing.
@visibleForTesting, read / write
hashCode int
The hash code for this object.
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

add(T data) → void
Alias method of call.
override
call(T data) → void
Adds event to the sink.
close() → void
Closes the sink.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
testSinkDone() Future<void>
For only testing.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited