when method Null safety
this method returns a future object that is completed when the dispatching action is satisfied the given predicate
Implementation
@protected
Future<Object> when(bool Function(Object action) predicate, {Cubix? cubix}) {
final completer = Completer<Object>();
cubix ??= this.cubix;
VoidCallback? removeListener;
removeListener = cubix.when((action) {
if (predicate(action)) {
removeListener?.call();
completer.complete(action);
}
});
dispatcher.on(dispose: removeListener);
return completer.future;
}