You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,15 +52,33 @@ We also support serialized classes with `hydrate` and `persist` arguments.
52
52
```dart
53
53
final user$ = HydratedSubject<User>(
54
54
"user",
55
-
hydrate: (String s) => User.fromJSON(s),
56
-
persist: (User user) => user.toJSON(),
55
+
hydrate: (String s) => User.fromJson(s),
56
+
persist: (User user) => user.toJson(),
57
57
);
58
58
```
59
59
60
60
## Reliable
61
61
62
62
Hydrated is mock tested with all supported types and is dogfooded by its creator.
63
63
64
+
## Extensible
65
+
66
+
Hydrated supports any key-value data storages -- just implement the `KeyValueStore` interface
67
+
and you will be able to use *hive*, *flutter_secure_storage* or any other persistence solution of your choice.
68
+
69
+
```dart
70
+
class MyAwesomeKeyValueStore implements KeyValueStore {
71
+
/// your implementation here...
72
+
}
73
+
74
+
final user = HydratedSubject<User>(
75
+
"user",
76
+
hydrate: (String s) => User.fromJson(s),
77
+
persist: (User user) => user.toJson(),
78
+
keyValueStore: MyAwesomeKeyValueStore()
79
+
);
80
+
```
81
+
64
82
## Demo
65
83
66
84
<imgalt="demo of Hydrated BehaviorSubject between app restarts"src="https://raw.githubusercontent.com/lukepighetti/hydrated/master/doc/hydrated.gif"width="400">
0 commit comments