Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "src/modules/state/makeTimeTravelable"

Index

Functions

Functions

Const makeTimeTravelable

  • makeTimeTravelable<T>(observable$: Observable<T>): [Observable<[T, [T, number][], number, number]>, setIndex, Observable<number>, (Anonymous function), (Anonymous function)]
  • Turns an observable into a time travelable version of itself.

    It does this by creating a Subject to sink/stream the selected historic index.

    Then it it creates stateWithHistory$ which is just using the scan operator to keep track of all emitted values.

    A final index$ observable is created that only emits index values that are within the bounds of the history array's length.

    A final state$ observable is created by combining index$ and stateWithHistory$ to either select state from the history array or return the active, current state if the index is -1

    The return value of this function is a thruple of: 0: The final state$ observable 1: A dispatch function for setting the selected index 2: The index$ observable emitting both the index and the maximum

    Type parameters

    • T

    Parameters

    • observable$: Observable<T>

    Returns [Observable<[T, [T, number][], number, number]>, setIndex, Observable<number>, (Anonymous function), (Anonymous function)]

Generated using TypeDoc