OnBuilder<T>.all constructor

OnBuilder<T>.all({
  1. Key? key,
  2. IObservable<T>? listenTo,
  3. List<IObservable>? listenToMany,
  4. OnIdle? onIdle,
  5. required OnWaiting onWaiting,
  6. required OnError onError,
  7. required OnData<T> onData,
  8. SideEffects<T>? sideEffects,
  9. ShouldRebuild? shouldRebuild,
  10. Object? watch()?,
  11. String? debugPrintWhenRebuild,
})

Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.

For each OnBuilder widget flavor there is method like equivalent:

//Widget-like
OnBuilder(
    listenTo: counter,
    builder: () => Text('${counter.state}'),
),

//Method-like
counter.rebuild(
    () => Text('{counter.state}'),
),
//
//Widget-like
OnBuilder.data(
    listenTo: counter,
    builder: (data) => Text('$data')),
),

//Method-like
counter.rebuild.onData(
    (data) => Text(data),
),

//Widget-like
OnBuilder.all(
    listenTo: counter,
    onIdle: () => Text('onIdle'),
    onWaiting: () => Text('onWaiting'),
    onError: (err, errorRefresh) => Text('onError'),
    onData: (data) => Text('$data'),

)

//Method-like
counter.rebuild.onAll(
    onIdle: () => Text('onIdle'),
    onWaiting: () => Text('onWaiting'),
    onError: (err, errorRefresh) => Text('onError'),
    onData: (data) => Text('$data'),
),
//
//Widget-like
OnBuilder.orElse(
    listenTo: counter,
    onWaiting: () => Text('onWaiting'),
    orElse: (_) => Text('{counter.state}'),

),

//Method-like
counter.rebuild.onOrElse(
    onWaiting: () => Text('onWaiting'),
    orElse: (_) => Text('{counter.state}'),
),

Implementation

OnBuilder.all({
  Key? key,
  IObservable<T>? listenTo,
  List<IObservable>? listenToMany,
  OnIdle? onIdle,
  required OnWaiting onWaiting,
  required OnError onError,
  required OnData<T> onData,
  SideEffects<T>? sideEffects,
  ShouldRebuild? shouldRebuild,
  Object? Function()? watch,
  String? debugPrintWhenRebuild,
})  : assert(listenTo != null || listenToMany != null),
      super(
        key: key,
        observers: (_) => listenTo != null
            ? [listenTo as ReactiveModelImp]
            : listenToMany!.cast<ReactiveModelImp>(),
        builder: (_, snap, ___) {
          return snap.onAll<Widget>(
            onIdle: onIdle,
            onWaiting: onWaiting,
            onError: onError,
            onData: (_) => onData(_),
          );
        },
        sideEffects: sideEffects,
        shouldRebuild: shouldRebuild,
      );