ReactiveX / rxdart

The Reactive Extensions for Dart
http://reactivex.io
Apache License 2.0
3.37k stars 270 forks source link

Notice that something new is added to ValueObservable #204

Closed tsuba3 closed 5 years ago

tsuba3 commented 5 years ago

I use ValueObservable in Flutter development with BLoC pattern. For testing, I want to cast a ValueObservable as a single-subscription stream, or detect that the bloc add something new into a ValueObservable.

For example:

bloc.submit();
await expectLater(bloc.isSubmitting, emits(true));
await expectLater(bloc.isSubmitting, emits(false)); // Actually emits true
brianegan commented 5 years ago

Hey there -- in this case, rather than doing two separate assertions on the same stream, it's usually easier to use the emitsInOrder operator, so you don't run into timing issues like this.

E.g.

bloc.submit();
expect(bloc.isSubmitting, emitsInOrder([true, false]);
brianegan commented 5 years ago

Heya @tsuba3, gonna close this out for now, but let let me know if my suggestion didn't work for ya!