Stone.js API
    Preparing search index...
    • 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.

      Type Parameters

      • State extends Record<string, any>

      Parameters

      Returns StoreDefinition<State>

      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.

      Type Parameters

      • State extends Record<string, any>

      Parameters

      Returns MetaStore<State>

      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 }
      )