isWaiting method

bool isWaiting(
  1. Object actionOrTypeOrList
)

You can use isWaiting to check if:

  • A specific async ACTION is currently being processed.
  • An async action of a specific TYPE is currently being processed.
  • If any of a few given async actions or action types is currently being processed.

If you wait for an action TYPE, then it returns false when:

  • The ASYNC action of the type is NOT currently being processed.
  • If the type is not really a type that extends ReduxAction.
  • The action of the type is a SYNC action (since those finish immediately).

If you wait for an ACTION, then it returns false when:

  • The ASYNC action is NOT currently being processed.
  • If the action is a SYNC action (since those finish immediately).

Trying to wait for any other type of object will return null and throw a StoreException after the async gap.

Examples:

// Waiting for an action TYPE:
dispatch(MyAction());
if (store.isWaiting(MyAction)) { // Show a spinner }

// Waiting for an ACTION:
var action = MyAction();
dispatch(action);
if (store.isWaiting(action)) { // Show a spinner }

// Waiting for any of the given action TYPES:
dispatch(BuyAction());
if (store.isWaiting([BuyAction, SellAction])) { // Show a spinner }

Implementation

bool isWaiting(Object actionOrTypeOrList) => _store.isWaiting(actionOrTypeOrList);