ixfx
    Preparing search index...

    Type Alias Wrapped<TIn>

    Wrapped Reactive for object-oriented access

    type Wrapped<TIn> = {
        annotate: <TAnnotation>(
            transformer: (value: TIn) => TAnnotation,
        ) => Wrapped<{ annotation: TAnnotation; value: TIn }>;
        annotateWithOp: <TOut>(
            op: ReactiveOp<TIn, TOut>,
        ) => Wrapped<{ annotation: TOut; value: TIn }>;
        average: (options?: Partial<OpMathOptions>) => Wrapped<number>;
        chunk: (options: Partial<ChunkOptions>) => Wrapped<TIn[]>;
        combineLatestToArray: <const T extends readonly ReactiveOrSource<any>[]>(
            sources: T,
            options: Partial<CombineLatestOptions>,
        ) => Wrapped<RxValueTypes<T>>;
        combineLatestToObject: <
            const T extends Record<string, ReactiveOrSource<any>>,
        >(
            sources: T,
            options: { name: string } & Partial<CombineLatestOptions>,
        ) => Wrapped<RxValueTypeObject<T>>;
        debounce: (options: Partial<DebounceOptions>) => Wrapped<TIn>;
        enacts: { setHtmlText: (options: SetHtmlOptions) => () => void };
        field: <TSource, TFieldType>(
            fieldName: keyof TIn,
            options: Partial<FieldOptions<TSource, TFieldType>>,
        ) => Wrapped<TFieldType>;
        filter: (
            predicate: FilterPredicate<TIn>,
            options: Partial<InitStreamOptions>,
        ) => Wrapped<TIn>;
        max: (options?: Partial<OpMathOptions>) => Wrapped<number>;
        min: (options?: Partial<OpMathOptions>) => Wrapped<number>;
        onValue: (callback: (value: TIn) => void) => void;
        source: Reactive<TIn>;
        split: (options?: Partial<SplitOptions>) => Wrapped<TIn>[];
        splitLabelled: <K extends keyof TIn>(
            ...labels: K[],
        ) => Record<K, Wrapped<TIn>>;
        sum: (options?: Partial<OpMathOptions>) => Wrapped<number>;
        switcher: <
            TRec extends Record<string, FilterPredicate<TIn>>,
            TLabel extends keyof TRec,
        >(
            cases: TRec,
            options: Partial<SwitcherOptions>,
        ) => Record<TLabel, Wrapped<TIn>>;
        syncToArray: <const T extends readonly ReactiveOrSource<any>[]>(
            reactiveSources: T,
            options?: Partial<SyncOptions>,
        ) => Wrapped<[TIn, ...RxValueTypes<T>]>;
        syncToObject: <const T extends Record<string, ReactiveOrSource<any>>>(
            reactiveSources: T,
            options?: { name?: string } & Partial<SyncOptions>,
        ) => Wrapped<RxValueTypeObject<T>>;
        tally: (options?: Partial<TallyOptions>) => Wrapped<number>;
        tapOps: <TOut>(
            source: ReactiveOrSource<TIn>,
            ...ops: ReactiveOp<TIn, TOut>[],
        ) => Wrapped<TIn>;
        tapProcess: <T2, T3, T4, T5, T6>(
            ...processors: Processors<TIn, T2, T3, T4, T5, T6>,
        ) => Wrapped<TIn>;
        tapStream: (divergedStream: ReactiveWritable<TIn>) => Wrapped<TIn>;
        throttle: (options: Partial<ThrottleOptions>) => Wrapped<TIn>;
        timeoutPing: (options: TimeoutPingOptions) => Wrapped<TIn>;
        timeoutValue: <TTriggerValue>(
            options: TimeoutValueOptions<TTriggerValue>,
        ) => Wrapped<TIn | TTriggerValue>;
        toArray: (
            options: Partial<ToArrayOptions<TIn>>,
        ) => Promise<(TIn | undefined)[]>;
        toArrayOrThrow: (options: Partial<ToArrayOptions<TIn>>) => Promise<TIn[]>;
        transform: <TOut>(
            transformer: (value: TIn) => TOut,
            options?: Partial<TransformOpts>,
        ) => Wrapped<TOut>;
    }

    Type Parameters

    • TIn
    Index

    Properties

    annotate: <TAnnotation>(
        transformer: (value: TIn) => TAnnotation,
    ) => Wrapped<{ annotation: TAnnotation; value: TIn }>

    Annotate values with output from the annotation function. Returned values will be in the form { value:TIn, annotation:TAnnotation }

    Type declaration

      • <TAnnotation>(
            transformer: (value: TIn) => TAnnotation,
        ): Wrapped<{ annotation: TAnnotation; value: TIn }>
      • Type Parameters

        • TAnnotation

        Parameters

        • transformer: (value: TIn) => TAnnotation

        Returns Wrapped<{ annotation: TAnnotation; value: TIn }>

    annotateWithOp: <TOut>(
        op: ReactiveOp<TIn, TOut>,
    ) => Wrapped<{ annotation: TOut; value: TIn }>
    average: (options?: Partial<OpMathOptions>) => Wrapped<number>
    chunk: (options: Partial<ChunkOptions>) => Wrapped<TIn[]>

    Accumulate a chunk of values, emitted as an array

    Type declaration

    combineLatestToArray: <const T extends readonly ReactiveOrSource<any>[]>(
        sources: T,
        options: Partial<CombineLatestOptions>,
    ) => Wrapped<RxValueTypes<T>>
    combineLatestToObject: <const T extends Record<string, ReactiveOrSource<any>>>(
        sources: T,
        options: { name: string } & Partial<CombineLatestOptions>,
    ) => Wrapped<RxValueTypeObject<T>>
    debounce: (options: Partial<DebounceOptions>) => Wrapped<TIn>
    enacts: { setHtmlText: (options: SetHtmlOptions) => () => void }
    field: <TSource, TFieldType>(
        fieldName: keyof TIn,
        options: Partial<FieldOptions<TSource, TFieldType>>,
    ) => Wrapped<TFieldType>

    Pluck and emit a single field from values

    Type declaration

      • <TSource, TFieldType>(
            fieldName: keyof TIn,
            options: Partial<FieldOptions<TSource, TFieldType>>,
        ): Wrapped<TFieldType>
      • Type Parameters

        • TSource
        • TFieldType

        Parameters

        Returns Wrapped<TFieldType>

    filter: (
        predicate: FilterPredicate<TIn>,
        options: Partial<InitStreamOptions>,
    ) => Wrapped<TIn>

    Throws away values that don't match predicate

    Type declaration

    max: (options?: Partial<OpMathOptions>) => Wrapped<number>
    min: (options?: Partial<OpMathOptions>) => Wrapped<number>
    onValue: (callback: (value: TIn) => void) => void

    Listen for values

    Type declaration

      • (callback: (value: TIn) => void): void
      • Parameters

        • callback: (value: TIn) => void

        Returns void

    source: Reactive<TIn>
    split: (options?: Partial<SplitOptions>) => Wrapped<TIn>[]

    Converts one source stream into two, with values being emitted by both

    Type declaration

    splitLabelled: <K extends keyof TIn>(...labels: K[]) => Record<K, Wrapped<TIn>>

    Creates new streams for each case

    Type declaration

      • <K extends keyof TIn>(...labels: K[]): Record<K, Wrapped<TIn>>
      • Type Parameters

        • K extends keyof TIn

        Parameters

        • ...labels: K[]

        Returns Record<K, Wrapped<TIn>>

    sum: (options?: Partial<OpMathOptions>) => Wrapped<number>
    switcher: <
        TRec extends Record<string, FilterPredicate<TIn>>,
        TLabel extends keyof TRec,
    >(
        cases: TRec,
        options: Partial<SwitcherOptions>,
    ) => Record<TLabel, Wrapped<TIn>>

    Creates new streams for each case, sending values to the stream if they match the filter predicate

    Type declaration

    syncToArray: <const T extends readonly ReactiveOrSource<any>[]>(
        reactiveSources: T,
        options?: Partial<SyncOptions>,
    ) => Wrapped<[TIn, ...RxValueTypes<T>]>

    Emits values when this stream and any additional streams produce a value. The resulting stream is thus an array of values, each source at a given index. Waits to output a value until each stream has produced a value. Thus, the pace is determined by the slowest stream.

    Type declaration

    syncToObject: <const T extends Record<string, ReactiveOrSource<any>>>(
        reactiveSources: T,
        options?: { name?: string } & Partial<SyncOptions>,
    ) => Wrapped<RxValueTypeObject<T>>
    tally: (options?: Partial<TallyOptions>) => Wrapped<number>
    tapOps: <TOut>(
        source: ReactiveOrSource<TIn>,
        ...ops: ReactiveOp<TIn, TOut>[],
    ) => Wrapped<TIn>
    tapProcess: <T2, T3, T4, T5, T6>(
        ...processors: Processors<TIn, T2, T3, T4, T5, T6>,
    ) => Wrapped<TIn>

    Taps the stream, passing values to one or more 'processor' functions. This processing essentially happens in parallel, not affecting the main stream.

    // Stream of pointermove events with {x:0,y:0} as default
    const move = Rx.From.event(document.body, `pointermove`, {x:0,y:0});
    // Wrap it for fluent access
    const ptr = Rx.wrap(move)
    .tapProcess(
    // Create a string representation
    v => `${v.x},${v.y}`
    // Set to DOM
    v => {
    document.getElementById(`coords`).innerText = v;
    }
    )
    .onValue(value => {
    // 'value' will be original PointerEvent, since .tapProcess happened in parallel,
    // not affecting stream
    });

    Type declaration

      • <T2, T3, T4, T5, T6>(
            ...processors: Processors<TIn, T2, T3, T4, T5, T6>,
        ): Wrapped<TIn>
      • Type Parameters

        • T2
        • T3
        • T4
        • T5
        • T6

        Parameters

        • ...processors: Processors<TIn, T2, T3, T4, T5, T6>

          One-five processing functions

        Returns Wrapped<TIn>

    tapStream: (divergedStream: ReactiveWritable<TIn>) => Wrapped<TIn>
    throttle: (options: Partial<ThrottleOptions>) => Wrapped<TIn>

    Only allow values through if a minimum of time has elapsed. Throws away values. Ie. converts a fast stream into a slower one.

    Type declaration

    timeoutPing: (options: TimeoutPingOptions) => Wrapped<TIn>

    'Pings' reactive (if it supports it) if a value is not received within a given interval. Behaviour can be stopped using an abort signal.

    Type declaration

    timeoutValue: <TTriggerValue>(
        options: TimeoutValueOptions<TTriggerValue>,
    ) => Wrapped<TIn | TTriggerValue>

    Emits a value if source does not emit a value after interval has elapsed. This can be useful to reset a reactive to some 'zero' state if nothing is going on.

    If source emits faster than the interval, it won't get triggered.

    Default for 'timeout': 1000s.

    // Emit 'hello' if 'source' doesn't emit a value after 1 minute
    const r = Rx.timeoutValue(source, { value: 'hello', interval: { mins: 1 } });

    Can also emit results from a function or generator

    // Emits a random number if 'source' doesn't emit a value after 500ms
    const r = Rx.timeoutValue(source, { fn: Math.random, interval: 500 });

    If immediate option is true (default), the timer starts from stream initialisation. Otherwise it won't start until it observes the first value from source.

    toArray: (options: Partial<ToArrayOptions<TIn>>) => Promise<(TIn | undefined)[]>

    Copies values from source into an array.

    Type declaration

    toArrayOrThrow: (options: Partial<ToArrayOptions<TIn>>) => Promise<TIn[]>

    Copies values from source into an array, throwing an error if expected number of items is not reached

    Type declaration

    transform: <TOut>(
        transformer: (value: TIn) => TOut,
        options?: Partial<TransformOpts>,
    ) => Wrapped<TOut>

    Transforms all values

    Type declaration