Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "dispatch"

Index

Dispatch

Fancy Stuff

Dispatch

Dispatch

Dispatch<A>: (action: A) => void

The dispatch function.

Type parameters

  • A

Type declaration

    • (action: A): void
    • Parameters

      • action: A

      Returns void

Fancy Stuff

map

  • map<ChildAction, ParentAction>(actionMapper: (childAction: ChildAction) => ParentAction, dispatch: Dispatch<ParentAction>): Dispatch<ChildAction>
  • Maps a parent dispatch function to child dispatch function. The resulting function is memoized so it will be consistent for future calls. This makes it possible to avoid re-render in e.g. react becuase the dispach prop will not change like it would if a lambda like (a) => dispatch(mapper(a)) was used.

    Type parameters

    • ChildAction

    • ParentAction

    Parameters

    • actionMapper: (childAction: ChildAction) => ParentAction
        • (childAction: ChildAction): ParentAction
        • Parameters

          • childAction: ChildAction

          Returns ParentAction

    • dispatch: Dispatch<ParentAction>

    Returns Dispatch<ChildAction>

Generated using TypeDoc