-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move in memory store to core package
- Loading branch information
1 parent
d07d31a
commit f5115a1
Showing
7 changed files
with
30 additions
and
28 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
example/lib/shared/modules/profile/data/profile_repository.dart
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
library core; | ||
|
||
export 'json_reader.dart'; | ||
export 'managed_stream_builder.dart'; | ||
export 'named_page.dart'; | ||
export 'src/in_memory_store.dart'; | ||
export 'src/json_reader.dart'; | ||
export 'src/managed_stream_builder.dart'; | ||
export 'src/named_page.dart'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:rxdart/rxdart.dart'; | ||
|
||
/// An in-memory store backed by BehaviorSubject that can be used to | ||
/// store the data for all the fake repositories in the app. | ||
class InMemoryStore<T> { | ||
InMemoryStore(T initial) : _subject = BehaviorSubject<T>.seeded(initial); | ||
|
||
/// The BehaviorSubject that holds the data | ||
final BehaviorSubject<T> _subject; | ||
|
||
bool get isWaiting => !_subject.hasValue && !_subject.hasError; | ||
|
||
/// The output stream that can be used to listen to the data | ||
Stream<T> get stream => _subject.stream; | ||
|
||
/// A synchronous getter for the current value | ||
T get value => _subject.value; | ||
|
||
/// A setter for updating the value | ||
set value(T value) => _subject.add(value); | ||
|
||
/// Don't forget to call this when done | ||
void close() => _subject.close(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.