Class Zeit<State, DerivedState>

Type Parameters

  • State extends object

  • DerivedState

Constructors

  • Type Parameters

    • State extends object

    • DerivedState

    Parameters

    • initialState: State
    • compute: ((state) => DerivedState) = ...
        • (state): DerivedState
        • Parameters

          • state: State

          Returns DerivedState

    Returns Zeit<State, DerivedState>

Properties

_cursor: number = -1
_initialState: State
_snapshot: State
_stack: Command<State>[] = []
_state: State
_store: StoreApi<State & DerivedState>
onCommand?: ((command, id?) => void)

Type declaration

    • (command, id?): void
    • Parameters

      • command: Command<State>
      • Optional id: string

      Returns void

onPatch?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

onRedo?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

onReplaceHistory?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

onReset?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

onResetHistory?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

onUndo?: ((state) => void)

Type declaration

    • (state): void
    • Parameters

      • state: State

      Returns void

Accessors

  • get state(): State & DerivedState
  • Returns State & DerivedState

  • get store(): StoreApi<State & DerivedState>
  • Returns StoreApi<State & DerivedState>

Methods

  • Parameters

    • patchState: Partial<{
          [P in string | number | symbol]: Partial<({ [P in keyof State[P]]: Partial<{ [P in keyof State[P][P]]: Partial<{ [P in keyof State[P][P][P]]: Partial<{ [P in keyof State[P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P][P]]: Partial<...>; }>; }>; }>; }>; }>; })>
      }>
    • Optional id: string
    • shallow: boolean = false

    Returns Zeit<State, DerivedState>

  • 在正式更新状态之前执行最后的修改。

    默认的实现是直接返回了 merge(next, patchState) 的结果,也就是没有做任何修 改。在扩展 Zeit 类时重写这个方法来实现自定义的修改或者其他副作用(side effects),比如说日志,调试等等。请注意,此方法内执行的修改是无法撤销的。

    Parameters

    • next: State
    • _prev: State
    • _patch: Partial<{
          [P in string | number | symbol]: Partial<({ [P in keyof State[P]]: Partial<{ [P in keyof State[P][P]]: Partial<{ [P in keyof State[P][P][P]]: Partial<{ [P in keyof State[P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P][P]]: Partial<...>; }>; }>; }>; }>; }>; })>
      }>
    • Optional _id: string

    Returns State

  • Parameters

    • command: Command<State>
    • id: undefined | string = command.id

    Returns Zeit<State, DerivedState>

  • Parameters

    • state: State
    • Optional id: string

    Returns void

  • Parameters

    • state: State
    • Optional id: string

    Returns void

  • Parameters

    • patchState: Partial<{
          [P in string | number | symbol]: Partial<({ [P in keyof State[P]]: Partial<{ [P in keyof State[P][P]]: Partial<{ [P in keyof State[P][P][P]]: Partial<{ [P in keyof State[P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P][P]]: Partial<...>; }>; }>; }>; }>; }>; })>
      }>

    Returns Zeit<State, DerivedState>

  • Parameters

    • state: State

    Returns Zeit<State, DerivedState>

  • Parameters

    • history: Command<State>[]
    • cursor: number = ...

    Returns Zeit<State, DerivedState>

  • Parameters

    • command: Command<State>
    • id: undefined | string = command.id

    Returns Zeit<State, DerivedState>

  • Parameters

    • patchState: Partial<{
          [P in string | number | symbol]: Partial<({ [P in keyof State[P]]: Partial<{ [P in keyof State[P][P]]: Partial<{ [P in keyof State[P][P][P]]: Partial<{ [P in keyof State[P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P]]: Partial<{ [P in keyof State[P][P][P][P][P][P]]: Partial<...>; }>; }>; }>; }>; }>; })>
      }>

    Returns Zeit<State, DerivedState>

Generated using TypeDoc