bindActionCreator

void Function() bindActionCreator<A extends Action>(

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

Binds a single action creator to a dispatch function.

This turns an action creator into a function that directly dispatches the action when called.

Example:

Action increment() => Increment();
final boundIncrement = bindActionCreator(increment, store.dispatch);
boundIncrement(); // dispatches Increment action

Implementation

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