-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@xstate/store] Event emitter #5064
Conversation
🦋 Changeset detectedLatest commit: 996b511 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@tonivj5 Do you have any thoughts on this to share? (responding to emoji reaction) |
packages/xstate-store/src/types.ts
Outdated
export interface StoreSchemas { | ||
emitted?: Record<string, { _output: unknown }>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not sure why this is introduced here. It should be a separate followup PR. I also don't necessarily understand why this one only adds support for schema.emitted
. What about schema.events
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move schema types to a separate PR
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
@Andarist Types are failing |
hey @davidkpiano! My "corcerns" (or doubts) about these changes were about make zod "first citizen", I love the idea itself, but I personally prefer to avoid "hard" coupling and let it open to integrate other solutions using adapters or some other kind of technique (and I think @colinhacks is drafting an awesome solution to achive it with https://github.com/standard-schema/standard-schema). Zod is a brilliant piece of software, I've used it before although I love and use other libraries too as https://github.com/sinclairzx81/typebox and I think this field is a moving target that it's going to beneficate from making it elegible. Anyway, I'm just passing through here so take my reactions and comments with a grain of salt 😅. I love from time to time review your work and check what's cooking here 😸 |
@tonivj5 You're in luck - we moved the Zod stuff out and that will probably be a separate PR later, if we decide to do it. |
You can now emit events from a store:
You can make emitted events type-safe via
createStore({ types: { … } })