-
-
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
feat(core): add actor ID to DoneActorEvent, ErrorActorEvent #4942
feat(core): add actor ID to DoneActorEvent, ErrorActorEvent #4942
Conversation
🦋 Changeset detectedLatest commit: 8edf73b 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 |
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.
This looks great. I'm wondering if we should use actorId
instead of id
, since intuitively, id
is self-referential (e.g. the id
of the event) rather than something that references something else.
This changes `DoneActorEvent` (`xstate.done.actor.*`) and `ErrorActorEvent` (`xstate.error.actor.*`) to have an `actorId` prop which is equal to the ID of the Actor associated with the event. Previously, this information was only available by extracting it from the `type` property of the event object using string operations.
fc6fee0
to
689ebb6
Compare
New prop is now |
packages/core/test/invoke.test.ts
Outdated
@@ -3121,7 +3122,7 @@ describe('invoke', () => { | |||
on: { | |||
'*': { | |||
actions: ({ event }) => { | |||
actual.push(event.type); | |||
actual.push(event as any); |
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.
we shouldn't have to cast here, what is the reporter error without it?
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.
This test machine does not declare its event types, so any event it handles will be of type AnyEventObject
.
actual
is DoneActorEvent<void>[]
, so we need a type assertion here. We could cast to DoneActorEvent<void>
, but that seemed a little wordy. 🙂
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.
Previously, actual
was string[]
, which did not need a type assertion.
use `AnyEventObject` instead of `DoneActorEvent` in `invoke.test.ts` Co-authored-by: David Khourshid <davidkpiano@gmail.com>
@davidkpiano Suggestions committed |
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.
Just need to add a changeset (minor change: yarn changeset
) 🚀
cc. @Andarist
@davidkpiano Is that something I should be doing? |
Yes please |
@davidkpiano Done. Hope I did that right. It looks like a minor bump to me |
This changes
DoneActorEvent
(xstate.done.actor.*
) andErrorActorEvent
(xstate.error.actor.*
) to have anactorId
prop which is equal to the ID of the Actor associated with the event.Previously, this information was only available by extracting it from the
type
property of the event object using string operations.Updated a test for
DoneActorEvent
to prove thatactorId
gets passed, but may want the same test for anErrorActorEvent
.Ref: https://discord.com/channels/795785288994652170/1250894522616123494