Const
Readonly
annotate: (<V, TAnnotation>(annotator: ((input: V) => V & TAnnotation)) => (<In, TAnnotation>(source: ReactiveOrSource<In>) => Reactive<{ Readonly
annotateAnnotates the input stream using ReactiveOp as the source of annotations.
The output values will have the shape of { value: TIn, annotation: TAnnotation }
.
Meaning that the original value is stored under .value
, and the annotation under .annotation
.
// Emit values from an array
const r1 = Rx.run(
Rx.From.array([ 1, 2, 3 ]),
Rx.Ops.annotateWithOp(
// Add the 'max' operator to emit the largest-seen value
Rx.Ops.sum()
)
);
const data = await Rx.toArray(r1);
// Data = [ { value: 1, annotation: 1 }, { value: 2, annotation: 3 }, { value: 3, annotation: 6 } ]
Readonly
average: (<TIn>(options?: OpMathOptions) => ((source: ReactiveOrSource<TIn>) => Reactive<number>))Optional
options: OpMathOptionsReadonly
chunk: (<V>(options: Partial<ChunkOptions>) => ReactiveOp<V, V[]>)Takes a stream of values and chunks them up (by quantity or time elapsed), emitting them as an array.
Readonly
cloneReadonly
combineMerges values from several sources into a single source that emits values as an array.
Readonly
combineMerges values from several sources into a single source that emits values as an object.
Readonly
debounce: (<V>(options: Partial<DebounceOptions>) => ReactiveOp<V, V>)Debounce values from the stream. It will wait until a certain time has elapsed before emitting latest value.
Effect is that no values are emitted if input emits faster than the provided timeout.
See also: throttle
Readonly
drop: (<V>(predicate: ((value: V) => boolean)) => (<In>(source: ReactiveOrSource<In>) => Reactive<In>))Drops values from the input stream that match predicate
Readonly
elapsed: (<V>() => ReactiveOp<V, number>)Every upstream value is considered the target for interpolation. Output value interpolates by a given amount toward the target.
Readonly
field: (<TSource, TFieldType>(fieldName: keyof TSource, options: FieldOptions<TSource, TFieldType>) => ((source: ReactiveOrSource<TSource>) => Reactive<TFieldType>))Yields the value of a field from an input stream of values.
Eg if the source reactive emits { colour: string, size: number }
,
we might use field
to pluck out the colour
field, thus returning
a stream of string values.
Readonly
filter: (<V>(predicate: ((value: V) => boolean)) => (<In>(source: ReactiveOrSource<In>) => Reactive<In>))Filters the input stream, only re-emitting values that pass the predicate
Readonly
interpolate: (<TIn>(options?: Partial<OpInterpolateOptions>) => ((source: ReactiveOrSource<TIn>) => ReactivePingable<number>))Every upstream value is considered the target for interpolation. Output value interpolates by a given amount toward the target.
Optional
options: Partial<OpInterpolateOptions>Readonly
max: (<TIn>(options?: OpMathOptions) => ((source: ReactiveOrSource<TIn>) => Reactive<number>))Outputs the maxium numerical value of the stream. A value is only emitted when maximum increases.
Optional
options: OpMathOptionsReadonly
min: (<TIn>(options?: OpMathOptions) => ((source: ReactiveOrSource<TIn>) => Reactive<number>))Outputs the minimum numerical value of the stream. A value is only emitted when minimum decreases.
Optional
options: OpMathOptionsReadonly
pipe: (<TInput, TOutput>(...streams: (Reactive<any> & { Rest
...streams: (Reactive<any> & { Readonly
rank: (<TIn>(rank: RankFunction<TIn>, options?: RankOptions & Partial<InitStreamOptions> & { Optional
options: RankOptions & Partial<InitStreamOptions> & { Readonly
singleReadonly
split: (<V>(options?: Partial<SplitOptions>) => ((source: ReactiveOrSource<V>) => ReactiveStream<V>[]))Readonly
splitReadonly
sum: (<TIn>(options?: OpMathOptions) => ((source: ReactiveOrSource<TIn>) => Reactive<number>))Optional
options: OpMathOptionsReadonly
switcher: (<TValue, TRec, TLabel>(cases: TRec, options?: Partial<SwitcherOptions>) => ((source: ReactiveOrSource<TValue>) => Record<TLabel, Reactive<TValue>>))Readonly
syncReadonly
syncReadonly
tally: (<TIn>(options?: TallyOptions) => ((source: ReactiveOrSource<TIn>) => Reactive<number>))Optional
options: TallyOptionsReadonly
tapRest
...ops: ReactiveOp<In, Out>[]Readonly
tapReadonly
tapReadonly
throttle: (<V>(options: Partial<ThrottleOptions>) => ((source: ReactiveOrSource<V>) => Reactive<V>))Throttle values from the stream. Only emits a value if some minimum time has elapsed.
Readonly
timeoutReadonly
timeoutTrigger a value if 'source' does not emit a value within an interval. Trigger value can be a fixed value, result of function, or step through an iterator.
Readonly
transform: (<In, Out>(transformer: ((value: In) => Out), options?: Partial<TransformOpts>) => ReactiveOp<In, Out>)Readonly
withReactive where last (or a given initial) value is available to read
Annotates values with the result of a function. The input value needs to be an object.
For every value
input
emits, run it throughannotator
, which should return the original value with additional fields.Conceptually the same as
transform
, just with typing to enforce result values are V & TAnnotation