Last updated:
0 purchases
keeper
Keeper #
Keeper simplifies storage of state. Just point where it should be saved, and keeper takes care of the rest. You don't need to write code to load, save, and convert data, keeper takes care of that for you.
đ Features #
â
Sync storage
đ§ Async storage*
â
Store single async value
â Store value in sync key
â MobX store support
â Function types
â Observe storage changes
â
Extensible for many storage containers
Supported storage containers:
â
In-memory storage
â
Hive storage (through keeper_hive)
* supports one async annotation per field, sync annotation not supported for asynchronous field
â
Available | đ§ Under development | â Unsupported
đ ī¸ Getting started #
Keeper relies on code generation to save you the trouble of writing storage code. The code is generated by keeper_codegen which requires build_runner.
â ī¸ This is an experimental project. Use with caution.
đģ Usage #
In pubspec.yaml:
dependencies:
keeper: ^0.0.1
dev_dependencies:
build_runner: ^2.1.5 # check for recent version on pub.dev
keeper_codegen: ^0.0.1 # check for recent version on pub.dev
copied to clipboard
In your Dart file import keeper:
import 'package:keeper/keeper.dart';
copied to clipboard
Set up the storage key:
KeepKey counterValue() => MemoryKeep().key('counter_value');
copied to clipboard
And set up the class:
part 'counter.g.dart';
class Counter = _Counter with _$CounterKeeper;
@kept
class _Counter {
@At(counterValue)
int value = 0;
void increment() {
value++;
}
}
copied to clipboard
When the value changes it will now be automatically stored.
Different storage mechanisms may require different initialization.
âšī¸ Additional information #
Contributions and bug reports are welcomed! Please include relevant information to help solve the bugs.
This project is licensed under The MIT License (MIT) available at LICENSE.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.