Last active
November 6, 2022 07:11
-
-
Save pr0xyMity/7f4311e20310c2a8f87859aa19d88a02 to your computer and use it in GitHub Desktop.
BehaviorSubject
This file contains hidden or 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
| class InMemoryState<T> { | |
| InLocalMemoryState(T initial) : _subject = BehaviorSubject<T>.seeded(initial); | |
| // INIT | |
| final BehaviorSubject<T> _subject; | |
| // GET - synchronous | |
| T get value => _subject.value; | |
| // SET | |
| set value(T value) => _subject.add(value); | |
| // STREAM | |
| Stream<T> get stream => _subject.stream; | |
| // CLOSE | |
| void close() => _subject.close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment