diff --git a/CHANGELOG.md b/CHANGELOG.md index 885255a..e1d66c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.1.0 + +- Add support for a generic `KeyValueStore` interface. +- Add an extensive unit-test suite. + ## 2.0.1 - Restore `BehaviorSubject` behavior of `HydratedSubject`. diff --git a/README.md b/README.md index 7f85bf3..5c299b1 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ We also support serialized classes with `hydrate` and `persist` arguments. ```dart final user$ = HydratedSubject<User>( "user", - hydrate: (String s) => User.fromJSON(s), - persist: (User user) => user.toJSON(), + hydrate: (String s) => User.fromJson(s), + persist: (User user) => user.toJson(), ); ``` @@ -61,6 +61,24 @@ final user$ = HydratedSubject<User>( Hydrated is mock tested with all supported types and is dogfooded by its creator. +## Extensible + +Hydrated supports any key-value data storages -- just implement the `KeyValueStore` interface +and you will be able to use *hive*, *flutter_secure_storage* or any other persistence solution of your choice. + +```dart +class MyAwesomeKeyValueStore implements KeyValueStore { + /// your implementation here... +} + +final user = HydratedSubject<User>( + "user", + hydrate: (String s) => User.fromJson(s), + persist: (User user) => user.toJson(), + keyValueStore: MyAwesomeKeyValueStore() +); +``` + ## Demo <img alt="demo of Hydrated BehaviorSubject between app restarts" src="https://raw.githubusercontent.com/lukepighetti/hydrated/master/doc/hydrated.gif" width="400"> diff --git a/pubspec.yaml b/pubspec.yaml index 77d64ba..79a39ec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: hydrated description: An automatically persisted BehaviorSubject with simple hydration for Flutter. Intended to be used with the BLoC pattern. -version: 2.0.1 +version: 2.1.0 homepage: https://github.com/solid-software/hydrated environment: