Const
Readonly
annotate: <V, TAnnotation>(Readonly
annotateWithOp: <TIn, TAnnotation>(Annotates 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 = number>(Readonly
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
cloneFromFields: <V>() => ReactiveOp<V, V>Readonly
combineLatestToArray: <const T extends readonly ReactiveOrSource<any>[]>(Merges values from several sources into a single source that emits values as an array.
Readonly
combineLatestToObject: <const T extends Record<string, ReactiveOrSource<any>>>(Merges 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>(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 extends object, 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>(Filters the input stream, only re-emitting values that pass the predicate
Readonly
interpolate: <TIn = number>(Every upstream value is considered the target for interpolation. Output value interpolates by a given amount toward the target.
Readonly
max: <TIn = number>(Outputs the maxium numerical value of the stream. A value is only emitted when maximum increases.
Readonly
min: <TIn = number>(Outputs the minimum numerical value of the stream. A value is only emitted when minimum decreases.
Readonly
pipe: <TInput, TOutput>(Readonly
rank: <TIn>(Readonly
singleFromArray: <V>(Readonly
split: <V>(Readonly
splitLabelled: <V>(Readonly
sum: <TIn = number>(Readonly
switcher: <Readonly
syncToArray: <const T extends readonly ReactiveOrSource<any>[]>(Readonly
syncToObject: <const T extends Record<string, ReactiveOrSource<any>>>(Readonly
tally: <TIn>(Readonly
tapOps: <In, Out>(Readonly
tapProcess: <In>(processor: (value: In) => any) => ReactiveOp<In, In>Readonly
tapStream: <In>(divergedStream: ReactiveWritable<In>) => ReactiveOp<In, In>Readonly
throttle: <V>(Throttle values from the stream. Only emits a value if some minimum time has elapsed.
Readonly
timeoutPing: <V>(options: TimeoutPingOptions) => (source: ReactiveOrSource<V>) => Reactive<V>Readonly
timeoutValue: <V, TTriggerValue>(Trigger 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>(Readonly
withValue: <V>(opts: Partial<WithValueOptions<V>>) => ReactiveOp<V, V>Reactive 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