BackpressureStreamTransformer<S, T> class
A highly customizable StreamTransformer which can be configured to serve any of the common rx backpressure operators.
The StreamTransformer works by creating windows, during which it buffers events to a Queue.
The StreamTransformer works by creating windows, during which it buffers events to a Queue. It uses a WindowStrategy to determine how and when a new window is created.
onWindowStart and onWindowEnd are handlers that fire when a window opens and closes, right before emitting the transformed event.
startBufferEvery allows to skip events coming from the source Stream.
ignoreEmptyWindows can be set to true, to allow events to be emitted at the end of a window, even if the current buffer is empty. If the buffer is empty, then an empty List will be emitted. If false, then nothing is emitted on an empty buffer.
dispatchOnClose will cause the remaining values in the buffer to be emitted when the source Stream closes. When false, the remaining buffer is discarded on close.
- Inheritance
-
- Object
- StreamTransformerBase<
S, T> - BackpressureStreamTransformer
- Implementers
Constructors
-
BackpressureStreamTransformer(WindowStrategy strategy, Stream windowStreamFactory(S event)?, {T onWindowStart(S event)?, T onWindowEnd(List<
S> queue)?, int startBufferEvery = 0, bool closeWindowWhen(List<S> queue)?, bool ignoreEmptyWindows = true, bool dispatchOnClose = true, int? maxLengthQueue}) -
Constructs a StreamTransformer which buffers events emitted by the
Stream that is created by
windowStreamFactory
.
Properties
-
closeWindowWhen
→ bool Function(List<
S> queue)? -
Predicate which determines when the current window should close
final
- dispatchOnClose → bool
-
Toggle to prevent, or allow the final set of events to be dispatched
when the source Stream closes
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ignoreEmptyWindows → bool
-
Toggle to prevent, or allow windows that contain
no events to be dispatched
final
- maxLengthQueue → int?
-
Maximum length of the buffer.
Specify this value to avoid running out of memory when adding too many events to the buffer.
If it's
null
, maximum length of the buffer is unlimited.final -
onWindowEnd
→ T Function(List<
S> queue)? -
Handler which fires when the window closes
final
- onWindowStart → T Function(S event)?
-
Handler which fires when the window opens
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startBufferEvery → int
-
Used to skip an amount of events
final
- strategy → WindowStrategy
-
Determines how the window is created
final
- windowStreamFactory → Stream Function(S event)?
-
Factory method used to create the Stream which will be buffered
final
Methods
-
bind(
Stream< S> stream) → Stream<T> -
Transforms the provided
stream
.override -
cast<
RS, RT> () → StreamTransformer< RS, RT> -
Provides a
StreamTransformer<RS, RT>
view of this stream transformer.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited