on method

  1. @Deprecated('Will be removed because of deprecation of `doFuture`')
Future<T> on(
  1. WidgetModel listener, {
  2. void onError(
    1. Object error
    )?,
})

Do future on specified listener

await Future.value("wow").on(wm).then(result.add);
await Future.value("rly").on(wm).then(result.add);

Implementation

@Deprecated('Will be removed because of deprecation of `doFuture`')
Future<T> on(
  WidgetModel listener, {
  void Function(Object error)? onError,
}) {
  final completer = Completer<T>();
  listener.doFuture<T>(
    this,
    completer.complete,
    onError: (e) {
      onError?.call(e);
      completer.completeError(e);
    },
  );

  return completer.future;
}