createDispatcher

void Function() createDispatcher<A extends Action>(

  1. A actionCreator(),
  2. void dispatch(
    1. Action
    )
)

Creates a dispatcher function for a specific action type.

This is a convenience for creating bound action creators inline.

Example:

final dispatchIncrement = createDispatcher(
  () => Increment(),
  store.dispatch,
);
dispatchIncrement(); // automatically dispatches

Implementation

void Function() createDispatcher<A extends Action>(
  A Function() actionCreator,
  void Function(Action) dispatch,
) =>
    () => dispatch(actionCreator());