Created
September 15, 2018 09:02
-
-
Save kuronekomichael/dfeb0bd5f572cfcfdcc397a3e1cf67b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:rxdart/rxdart.dart'; | |
import 'package:test/test.dart'; | |
void main() { | |
test('BehaviorSubjectのサンプル', () { | |
BehaviorSubject<int> subject = new BehaviorSubject<int>(); | |
// 1, 2をStreamに流す。しかしこの時点ではListenerがいないので配信されない | |
subject.sink.add(1); | |
subject.sink.add(2); | |
// 1, 2は流れてしまった後に、Listenerを追加。最後の要素の2を受け取ることができる | |
subject.listen(expectAsync1((int data) { | |
expect(data, 2); | |
})); | |
// さらに別のListenerも追加。Broadcastなので、こちらでも受信できる | |
subject.listen(expectAsync1((int data) { | |
expect(data, 2); | |
})); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment