watchStatus<T> static method
LxWorker<LxStatus<T> >
watchStatus<T>(
- LxReactive<
LxStatus< source, {T> > - void onIdle()?,
- void onWaiting()?,
- void onSuccess(
- T value
- void onError(
- Object error
- dynamic onProcessingError(
- Object error,
- StackTrace stackTrace
Watches an async source and triggers callbacks for specific state transitions.
Implementation
static LxWorker<LxStatus<T>> watchStatus<T>(
LxReactive<LxStatus<T>> source, {
void Function()? onIdle,
void Function()? onWaiting,
void Function(T value)? onSuccess,
void Function(Object error)? onError,
Function(Object error, StackTrace stackTrace)? onProcessingError,
}) {
return LxWorker<LxStatus<T>>(
source,
(status) {
if (status is LxIdle<T>) {
return onIdle?.call();
} else if (status is LxWaiting<T>) {
return onWaiting?.call();
} else if (status is LxSuccess<T>) {
return onSuccess?.call(status.value);
} else if (status is LxError<T>) {
return onError?.call(status.error);
}
},
onProcessingError: onProcessingError,
);
}