Function dispatchAction

  • Dispatches an action to the state container (registered with the given containerId).

    You can invoke this function from anywhere in your application, in hook context or outside of it. There is no need for action creators or any other boilerplate.

    If there is no container registered, function would print (but not throw) an error. So, effectively, the function call in such case gets ignored.

    Type Parameters

    • TState extends Object

    • TAction extends Action

    Parameters

    • args: {
          action: TAction;
          containerId: string;
          immediateState?: Partial<TState>;
      }
      • action: TAction

        The action object

      • containerId: string

        The id of the container to which the action should be dispatched. If the container is not registered, the function will print a message, but will not throw an error.

      • Optional immediateState?: Partial<TState>

        Implements advanced scenario, in most cases you can ignore this.

        Sets some selected attributes to state "immediately" before waiting for action to get completely executed.

        The immediateState is a kind of "promise" the state (whole or particular attributes) will look like declared AFTER the action gets executed (await reducer() call gets done).

        Where it can be useful: in some of the React "asynchronous" aspects, where getContainer() calls might return inappropriate state.

    Returns void

Generated using TypeDoc