Class TimedState<S, I>

TimedState works similar to TimedQueue, but instead of saving a list of all items pushed, it reduces the state on each push.

Type Parameters

  • S
  • I

Constructors

Properties

initState: (() => S)

Type declaration

    • (): S
    • Returns S

itemLimit: number = 100

State will be flushed when it reaches this number of items.

length: number = 0
onFlush: ((state) => void) = ...

Method that will be called when state is flushed.

Type declaration

    • (state): void
    • Parameters

      • state: S

      Returns void

reducer: ((state, item) => S)

Type declaration

    • (state, item): S
    • Parameters

      • state: S
      • item: I

      Returns S

state: S = ...
timeLimit: number = 5_000

State will be flushed after this many milliseconds.

timer: any = null

Methods