ECOSYSTEM / STORE

Reference

Every public name of janelkit-store.

Ecosystem package janelkit-store Shared application data: stores with actions, controlled writes and change tracking, one instance per application, and persistence. pip install janelkit-store
STORE · PAGE 8 / 8~1 min read
Alpha / 0.2 — These pages document JanelKit 0.2 and its packages. Each series (0.1, 0.2…) may change the public API, always with migration notes: see Changes and migration. The website uses Svelte; the desktop examples use Python and JanelKit, not JavaScript.

Public names

Import them from janelkit_store.

NameDescription
storeClass decorator: @store, @store(strict=True, persist="key").
fieldfield(default, bind=False, persist=True): a field with options.
useuse(Class, key=None): the instance of the running application. Without one, StoreError.
subscribesubscribe(instance, fn) -> cancel: fn(mutation) after each action that changes something.
snapshotsnapshot(instance) -> dict: a copy of the public fields.
resetreset(instance): the fields return to their defaults (an action named reset).
mutationsmutations(): the mutations of the running application.
MutationWhat subscribers receive: store, key, action, changes.
ChangeOne field of a Mutation: field, kind ("set" or "mutate"), old, new.
StoreErrorA write outside an action in a strict store, use() without an application, a class declared wrongly.
persistedpersisted(key, initial): a state that is remembered between launches. The same key gives the same object.
PersistedThe type of persisted: a State with key, file and flush().

English documentation based on the JanelKit source. For additional details, browse the source docs ↗.