Options
All
  • Public
  • Public/Protected
  • All
Menu

pullstate

Index

Type aliases

TInjectAsyncActionProps

TPullstateUpdateListener

TPullstateUpdateListener: () => void

Type declaration

    • (): void
    • Returns void

TReactionCreator

TReactionCreator<S>: (store: Store<S>) => TRunReactionFunction

Type parameters

  • S: object

Type declaration

    • (store: Store<S>): TRunReactionFunction
    • Parameters

      Returns TRunReactionFunction

TReactionFunction

TReactionFunction<S, T>: (watched: T, draft: Draft<S>, original: S, previousWatched: T) => void

Type parameters

  • S: object

  • T

Type declaration

    • (watched: T, draft: Draft<S>, original: S, previousWatched: T): void
    • Parameters

      • watched: T
      • draft: Draft<S>
      • original: S
      • previousWatched: T

      Returns void

TRunSubscriptionFunction

TRunSubscriptionFunction: () => void

Type declaration

    • (): void
    • Returns void

TStoreAction

TStoreAction<S>: (update: TStoreActionUpdate<S>) => void

Type parameters

  • S: object

Type declaration

TStoreActionUpdate

TStoreActionUpdate<S>: (updater: TUpdateFunction<S> | TUpdateFunction<S>[], patchesCallback?: undefined | ((patches: Patch[], inversePatches: Patch[]) => void)) => void

Type parameters

  • S: object

Type declaration

    • Parameters

      Returns void

TUpdateFunction

TUpdateFunction<S>: (draft: Draft<S>, original: S) => void
param

The mutable store state to change during this update (uses immer, which makes use of Proxies)

param

A readonly version of the store's state, for referencing during this update

Type parameters

  • S

    The store's state

Type declaration

    • (draft: Draft<S>, original: S): void
    • Parameters

      • draft: Draft<S>
      • original: S

      Returns void

Variables

Const PullstateContext

PullstateContext: Context<null | PullstateInstance<IPullstateAllStores>> = React.createContext<PullstateInstance | null>(null)

Const optPathDivider

optPathDivider: "~._.~" = "~._.~"

Let singleton

singleton: PullstateSingleton<any> | null = null

Functions

InjectAsyncAction

InjectStoreState

  • InjectStoreState<S, SS>(__namedParameters: { children: (output: SS) => ReactElement; store: Store<S>; on: any }): ReactElement
  • Type parameters

    • S: object = any

    • SS = any

    Parameters

    • __namedParameters: { children: (output: SS) => ReactElement; store: Store<S>; on: any }
      • children: (output: SS) => ReactElement
          • (output: SS): ReactElement
          • Parameters

            • output: SS

            Returns ReactElement

      • store: Store<S>
      • on: function
        • on(s: S): any

    Returns ReactElement

Const PullstateProvider

  • PullstateProvider<T>(__namedParameters: { children: any; instance: PullstateInstance<T> }): Element

applyPatchesToStore

  • applyPatchesToStore<S>(store: Store<S>, patches: Patch[]): void
  • Type parameters

    • S: object = any

    Parameters

    • store: Store<S>
    • patches: Patch[]

    Returns void

createAsyncAction

  • createAsyncAction<A, R, T, S>(action: TPullstateAsyncAction<A, R, T, S>, __namedParameters?: { cacheBreakHook: undefined | TPullstateAsyncCacheBreakHook<A, R, T, S>; forceContext: boolean; postActionHook: undefined | TPullstateAsyncPostActionHook<A, R, T, S>; shortCircuitHook: undefined | TPullstateAsyncShortCircuitHook<A, R, T, S>; subsetKey: undefined | ((args: A) => any) }): IOCreateAsyncActionOutput<A, R, T>
  • Type parameters

    Parameters

    • action: TPullstateAsyncAction<A, R, T, S>
    • Default value __namedParameters: { cacheBreakHook: undefined | TPullstateAsyncCacheBreakHook<A, R, T, S>; forceContext: boolean; postActionHook: undefined | TPullstateAsyncPostActionHook<A, R, T, S>; shortCircuitHook: undefined | TPullstateAsyncShortCircuitHook<A, R, T, S>; subsetKey: undefined | ((args: A) => any) } = {}
      • cacheBreakHook: undefined | TPullstateAsyncCacheBreakHook<A, R, T, S>
      • forceContext: boolean
      • postActionHook: undefined | TPullstateAsyncPostActionHook<A, R, T, S>
      • shortCircuitHook: undefined | TPullstateAsyncShortCircuitHook<A, R, T, S>
      • subsetKey: undefined | ((args: A) => any)

    Returns IOCreateAsyncActionOutput<A, R, T>

createAsyncActionDirect

  • createAsyncActionDirect<A, R, S>(action: (args: A) => Promise<R>, options?: ICreateAsyncActionOptions<A, R, string, S>): IOCreateAsyncActionOutput<A, R>
  • Type parameters

    Parameters

    • action: (args: A) => Promise<R>
        • (args: A): Promise<R>
        • Parameters

          • args: A

          Returns Promise<R>

    • Default value options: ICreateAsyncActionOptions<A, R, string, S> = {}

    Returns IOCreateAsyncActionOutput<A, R>

createPullstateCore

errorResult

  • errorResult<R, T>(tags?: (EAsyncEndTags | T)[], message?: string): IAsyncActionResultNegative<T>
  • Type parameters

    • R = any

    • T: string = string

    Parameters

    • Default value tags: (EAsyncEndTags | T)[] = []
    • Default value message: string = ""

    Returns IAsyncActionResultNegative<T>

makeReactionFunctionCreator

makeSubscriptionFunction

  • makeSubscriptionFunction<S, T>(store: Store<S>, watch: (state: S) => T, listener: (watched: T, allState: S, previousWatched: T, uid?: undefined | string) => void): TRunSubscriptionFunction
  • Type parameters

    • S: object

    • T

    Parameters

    • store: Store<S>
    • watch: (state: S) => T
        • (state: S): T
        • Parameters

          • state: S

          Returns T

    • listener: (watched: T, allState: S, previousWatched: T, uid?: undefined | string) => void
        • (watched: T, allState: S, previousWatched: T, uid?: undefined | string): void
        • Parameters

          • watched: T
          • allState: S
          • previousWatched: T
          • Optional uid: undefined | string

          Returns void

    Returns TRunSubscriptionFunction

registerInDevtools

  • registerInDevtools(stores: IPullstateAllStores, __namedParameters?: { namespace: string }): void

successResult

  • successResult<R, T>(payload?: R, tags?: (EAsyncEndTags | T)[], message?: string): IAsyncActionResultPositive<R, T>
  • Type parameters

    • R

    • T: string = string

    Parameters

    • Default value payload: R = (null as unknown) as R
    • Default value tags: (EAsyncEndTags | T)[] = []
    • Default value message: string = ""

    Returns IAsyncActionResultPositive<R, T>

update

  • Type parameters

    • S: object = any

    Parameters

    • store: Store<S>

      The store to run an update on

    • updater: TUpdateFunction<S> | TUpdateFunction<S>[]

      The update function, or an array of update functions

    • Optional patchesCallback: undefined | ((patches: Patch[], inversePatches: Patch[]) => void)

      A callback to keep track of the patches made during this update.

    Returns void

useInstance

useLocalStore

  • useLocalStore<S>(initialState: (() => S) | S, deps?: ReadonlyArray<any>): Store<S>
  • Create a local component-bound Pullstate Store, along with all the functionality that brings.

    Type parameters

    • S: object

    Parameters

    • initialState: (() => S) | S

      As in creating a regular Store, its initial state. Or, for optimization purposes, a function which calculates and returns the initial state (will only be run once per initialization or dependency change).

    • Optional deps: ReadonlyArray<any>

      If any of these dependencies change, a new Store will be created and returned (with whatever initial state is being passed in at this time too)

    Returns Store<S>

    A local component-bound Store

useStoreState

  • useStoreState<S>(store: Store<S>): S
  • useStoreState<S, SS>(store: Store<S>, getSubState: (state: S) => SS, deps?: ReadonlyArray<any>): SS
  • Type parameters

    • S: object = any

    Parameters

    Returns S

  • Type parameters

    • S: object = any

    • SS = any

    Parameters

    • store: Store<S>
    • getSubState: (state: S) => SS
        • (state: S): SS
        • Parameters

          • state: S

          Returns SS

    • Optional deps: ReadonlyArray<any>

    Returns SS

useStores

  • useStores<T>(): T

Generated using TypeDoc