github statelyai/xstate @xstate/store-angular@2.0.0

Major Changes

  • #5512 063416d Thanks @davidkpiano! - Modernize Store v4 package entrypoints.

    Use framework-specific packages such as @xstate/store-react and @xstate/store-solid instead of @xstate/store/react or @xstate/store/solid. The Store packages now publish ESM package entrypoints.

  • #5512 063416d Thanks @davidkpiano! - Add createStoreLogic(...) for reusable store definitions, and support creating stores from logic in framework hooks.

    const counterLogic = createStoreLogic({
      context: (input: { initialCount: number }) => ({
        count: input.initialCount
      }),
      on: {
        inc: (context) => ({ count: context.count + 1 })
      }
    });
    
    const store = useStore(counterLogic, { initialCount: 0 });

    If a store logic requires input, the input argument is also required:

    useStore(counterLogic, { initialCount: 0 });

    Framework hooks also preserve schema-derived context, event, and emitted event types when creating stores from config objects.

Patch Changes

Don't miss a new xstate release

NewReleases is sending notifications on new releases.