On<T>.or constructor

On<T>.or({
  1. T onIdle()?,
  2. T onWaiting()?,
  3. T onError(
    1. dynamic err,
    2. void refresh()
    )?,
  4. T onData()?,
  5. required T or(),
})

Set of callbacks to be invoked when the Injected model emits a notification with the corresponding state status.

onIdle, onWaiting, onError and onData are optional. Non defined ones default to the or callback.

To be forced to define all state status use On.all.

Implementation

factory On.or({
  T Function()? onIdle,
  T Function()? onWaiting,
  T Function(dynamic err, void Function() refresh)? onError,
  T Function()? onData,
  required T Function() or,
}) {
  return On._(
    onIdle: onIdle ?? or,
    onWaiting: onWaiting ?? or,
    onError: onError ?? (dynamic _, void Function() __) => or(),
    onData: onData ?? or,
    // onType: _OnType.when,
  );
}