droppable function

Rule droppable()

drop current dispatching if there is any instance of current action is dispatching

Implementation

Rule droppable() {
  return (dispatcher, next) {
    final last = dispatcher.dispatching.lastWhereOrNull((element) =>
        element.action.runtimeType == dispatcher.action.runtimeType);

    if (last != null) {
      dispatcher.cancel();
    } else {
      next();
    }
  };
}