Skip to content

Conversation

svemat01
Copy link

@svemat01 svemat01 commented Oct 6, 2025

This PR exposes additional utilities and types from the xstate-store package.

The new exports provide consumers with direct access to the createStoreTransition function and key store configuration types. This enhances flexibility and configurability, allowing for more advanced and custom store configurations to be built externally such as the currently stalled persist utility

  • Exports createStoreTransition utility function.
  • Exports StoreLogic, AnyStoreLogic, and AnyStoreConfig types.

Additional context: Discord thread

Expose the `createStoreTransition` utility.
Make internal store logic and configuration types publicly accessible.
This enables broader integration and customizability for store management.
Copy link

changeset-bot bot commented Oct 6, 2025

🦋 Changeset detected

Latest commit: 7c923e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@xstate/store Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svemat01
Copy link
Author

svemat01 commented Oct 6, 2025

Might also be worth considering adding in the storeConfigToLogic util from the persist branch so that custom middleware creators don't have to copy paste it.

Happy to add it in here as well or submit it as another PR if it's wanted

@davidkpiano
Copy link
Member

Might also be worth considering adding in the storeConfigToLogic util from the persist branch so that custom middleware creators don't have to copy paste it.

Happy to add it in here as well or submit it as another PR if it's wanted

Sure, you can expose that one too.

Can you also add a changeset? Just pnpm changeset and let's make it a minor.

@svemat01
Copy link
Author

svemat01 commented Oct 6, 2025

Just to clarify, that utility does not currently exist, it was only introduced in your persist branch so adding it here would include both adding that utility and potentially updating the undo helper to use it. So not just a quick extra export

createStoreWithProducer,
createStoreConfig
createStoreConfig,
createStoreTransition
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add some basic tests for this one? one test that would show (roughly) how you plan to use it would be helpful

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My actual usage is just copy pasting the persist utility from David's branch. Maybe the better course of action here is to maybe get that branch merged instead with perhaps these extra utils exposed should someone else want to build a custom utility as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are copy-pasting from the other branch then let's not reuse that sample as a test case for this exposed util, a new one (even a rather dummy one) should be added to tests. At the moment, this util is indirectly tested because other things use it but when exposing it as part of the public API we should have an extra smoke test for this new public interface~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants