rxNext<T> function
Future<T>
rxNext<T>(
- RxValueListenable<
T> rx, { - Duration timeLimit = const Duration(seconds: 10),
Wait the next change of a Atom.
The timeLimit
is 10 seconds by default.
Implementation
Future<T> rxNext<T>(
RxValueListenable<T> rx, {
Duration timeLimit = const Duration(seconds: 10),
}) async {
final completer = Completer<T>();
final disposable = rxObserver<T>(
() => rx.value,
effect: completer.complete,
);
final result = await completer.future.timeout(
timeLimit,
onTimeout: () => rx.value,
);
disposable();
return result;
}