expectRxChange<T> static method
Test that a reactive value changes to expected value
Implementation
static Future<void> expectRxChange<T>(
Rx<T> rx,
T expectedValue, {
Duration timeout = const Duration(seconds: 1),
}) async {
final completer = Completer<void>();
void listener() {
if (rx.value == expectedValue) {
completer.complete();
rx.removeListener(listener);
}
}
rx.addListener(listener);
try {
await completer.future.timeout(timeout);
} catch (e) {
rx.removeListener(listener);
throw Exception(
'Expected Rx value to change to $expectedValue but timeout occurred');
}
}