store library
Lark Store — Pinia-style state management.
Import separately to enable tree-shaking when not using stores.
Classes
- PersistenceAdapter
- Interface for store persistence (localStorage, etc).
Properties
-
storeRefRegistry
→ Map<
String, List< (String, Ref)> > -
Read-only access to the store refs (for HMR).
no setter
-
storeRegistry
→ Map<
String, dynamic> -
Read-only access to the store registry (for HMR and dev tools).
no setter
Functions
-
clearAllStores(
) → void - Clears all stores.
-
clearStore(
String name) → void - Clears a store (useful for testing or logout).
-
createCounterStore(
String name, {int initial = 0}) → ({Ref< int> count, void Function() decrement, void Function() increment, void Function() reset}) Function() - Creates a simple counter store.
-
createToggleStore(
String name, {bool initial = false}) → ({void Function() setFalse, void Function() setTrue, void Function() toggle, Ref< bool> value}) Function() - Creates a simple toggle store.
-
defineStore<
T> (String name, T setup(), {bool persist = false}) → T Function() - Defines a reactive store.
-
onStoreInit(
void callback(String)) → void - Register a callback to be called when a store is initialized.
-
registerStoreRef(
Ref r, String? name) → void -
setPersistenceAdapter(
PersistenceAdapter adapter) → void - Sets the persistence adapter.