CombineLatestNotifier<S, R> constructor

CombineLatestNotifier<S, R>(
  1. Iterable<ResultListenable<S>> notifiers, {
  2. required Combine<S, R> combineData,
  3. R? data,
  4. Result<R>? result,
  5. Duration? expiration,
  6. ResultNotifierCallback<R>? onReset,
  7. R onErrorReturn(
    1. Object? error
    )?,
  8. bool autoReset = false,
  9. bool refreshOnError = false,
  10. bool immediate = false,
  11. bool ignoreLoading = false,
})

Constructs a CombineLatestNotifier that combines the data from the provided source notifiers, using the specified combineData function.

If the source notifiers did not all contain data, the result of this notifier will be set to reflect this - see ResultIterableEffects.combine for more information.

If immediate is true, the effect will be executed immediately after the notifier is created. If ignoreLoading is true, any Loading state of the input notifiers will be ignored, and the previous result will be kept.

If expiration (i.e. cache expiration) is specified, the data will be considered stale after the specified duration has elapsed since the last update, meaning isFresh will return false.

Optionally provide callbacks for onFetch and onReset, which are called when fetch (refresh) or reset (and also cancellation and disposal) occurs.

If onErrorReturn is specified, the specified value will be returned as data when an error occurs, meaning this ResultNotifier will never be able to enter the Error state.

If autoReset (willAutoReset) is true, this notifier will automatically reset itself when all listeners are removed.

If refreshOnError (willRefreshOnError) is true, the refresh method will fetch new data when the current state is Error.

Implementation

CombineLatestNotifier(
  Iterable<ResultListenable<S>> notifiers, {
  required Combine<S, R> combineData,
  super.data,
  super.result,
  super.expiration,
  super.onReset,
  super.onErrorReturn,
  super.autoReset,
  super.refreshOnError,
  bool immediate = false,
  this.ignoreLoading = false,
}) : super(onFetch: _effect(notifiers, combineData)) {
  if (immediate) refresh(force: true);
  for (final source in notifiers) {
    _dependOnSource(source);
  }
}