A data definition, a store class, or a store factory.
The registration, ready to be handed to the blueprint.
// Data: state with no behaviour.
export const tasksStore = defineStore({ name: 'tasks', state: { items: [], filter: 'all' } })
// Class: the container builds it, so its actions can use injected services.
export const competitionStore = defineStore(CompetitionStore, { name: 'competition' })
// Factory: full control, the container in hand.
export const liveStore = defineStore(
(container) => StateStore.create({ scores: container.make('feed').initial() }),
{ name: 'live', isFactory: true }
)
Declare a store, imperatively.
Three forms, mirroring the rest of the framework. A data definition for state with no behaviour, a
class for a feature whose store carries actions, and a factory for full control over construction.
The class and factory forms are the imperative counterpart of @FeatureStore(): same declaration,
same registration, no decorators required. Everything ends up in stone.store.stores, which is
what the provider registers.
A data definition, a store class, or a store factory.
The name and lifetime, for the class and factory forms.
The registration, ready to be handed to the blueprint.
// Data: state with no behaviour.
export const tasksStore = defineStore({ name: 'tasks', state: { items: [], filter: 'all' } })
// Class: the container builds it, so its actions can use injected services.
export const competitionStore = defineStore(CompetitionStore, { name: 'competition' })
// Factory: full control, the container in hand.
export const liveStore = defineStore(
(container) => StateStore.create({ scores: container.make('feed').initial() }),
{ name: 'live', isFactory: true }
)
Declare a store, imperatively.
Three forms, mirroring the rest of the framework. A data definition for state with no behaviour, a class for a feature whose store carries actions, and a factory for full control over construction. The class and factory forms are the imperative counterpart of
@FeatureStore(): same declaration, same registration, no decorators required. Everything ends up instone.store.stores, which is what the provider registers.