loading<TAction extends Object?> method Null safety

bool loading<TAction extends Object?>(
  1. [bool predicate(
    1. ActionBase
    )?]
)

return true if there is any action dispatching

  cubix,loading()
  cubix.loading<ActionType>()
  cubix.loading((action) => action is ActionType1 || action is ActionType2 || action.prop == something);

Implementation

bool loading<TAction extends Object?>(
    [bool Function(ActionBase)? predicate]) {
  // using predicate to check action is dispatching or not
  if (predicate != null) {
    return dispatchers.any((element) => predicate(element.action));
  }
  // no action type
  if (null is TAction) {
    return dispatchers.isNotEmpty;
  }
  // with action type
  return dispatchers.any((element) => element.action is TAction);
}