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 type actionType is NOT currently being processed.
  • If actionType is not really a type that extends ReduxAction.
  • The action of type actionType 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 action is a SYNC action (since those finish immediately). Examples:
// Waiting for an action TYPE:
dispatch(MyAction());
if (isWaiting(MyAction)) { // Show a spinner }

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

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

Implementation

//
/// Examples:
///
/// ```dart
/// // Waiting for an action TYPE:
/// dispatch(MyAction());
/// if (isWaiting(MyAction)) { // Show a spinner }
///
/// // Waiting for an ACTION:
/// var action = MyAction();
/// dispatch(action);
/// if (isWaiting(action)) { // Show a spinner }
///
/// // Waiting for any of the given action TYPES:
/// dispatch(BuyAction());
/// if (isWaiting([BuyAction, SellAction])) { // Show a spinner }
/// ```
bool isWaiting(Object actionOrTypeOrList) => _store.isWaiting(actionOrTypeOrList);