Pacote
    Preparing search index...

    Function isType

    • Checks an action's type and narrows its payload and metadata types.

      Type Parameters

      • P

        Payload type of the action creator.

      • M

        Metadata type of the action creator.

      Parameters

      • match: ActionCreator<P, M>

        Action creator whose type to match.

      • action: Action

        Action to check.

      Returns action is Action<P, M>

      true when the action type matches the creator.

      import { createAction, isType } from '@pacote/flux-actions'

      const changeYear = createAction<number>('CHANGE_YEAR')
      const action = changeYear(1955)

      if (isType(changeYear, action)) {
      action.payload // number
      }