-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Deprecate send()
action creator
#3393
Conversation
🦋 Changeset detectedLatest commit: 2637bab 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 |
👇 Click on the image for a new way to code review
Legend |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
@Andarist Is this good to go? |
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.
It looks good to me, based on what little knowledge I have of this codebase so far 😊
packages/core/src/actions.ts
Outdated
): RaiseAction<TEvent> | SendAction<TContext, AnyEventObject, TEvent> { | ||
if (!isString(event)) { | ||
return send(event, { to: SpecialTargets.Internal }); | ||
event: Event<TEvent>, |
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 doesn't support expressions right now. I think that we should bring it to here - otherwise not all send
s can be refactored to raise
packages/core/src/actions.ts
Outdated
): RaiseAction<TEvent> { | ||
if (!isString(event) || options) { | ||
return send(event, { ...options, to: SpecialTargets.Internal }) 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.
IMHO we should stop piggybacking on send
here. It's especially important right now because you are suppressing the type checker to satisfy the declared return type. I wouldn't be surprised if we miss something that should be handled because of that, now or in the future. At times, we are checking action.type
after all.
packages/core/test/types.test.ts
Outdated
@@ -253,23 +253,23 @@ describe('Raise events', () => { | |||
{ | |||
actions: raise({ | |||
type: 'ALOHA' | |||
}) as any /* TODO: FIX */, | |||
}), |
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 created a spike for type-related improvements around this here: #3694
packages/core/test/actions.test.ts
Outdated
service.send('TO_B'); | ||
}); | ||
|
||
it('should be able to send an event to itself', (done) => { |
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 case has the very same title as the one above. This should be fixed as I'm not exactly sure what this test is testing here.
packages/core/test/actions.test.ts
Outdated
const service = interpret(machine).start(); | ||
|
||
service.onDone(() => done()); | ||
|
||
// Ensures that the delayed self-event is sent when in the `b` state | ||
service.send('TO_B'); |
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 isn't testing anything right now - it has 0 expectations ;p
466d4b1
to
b0bb50d
Compare
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
b0bb50d
to
1711278
Compare
# Conflicts: # packages/core/src/StateNode.ts # packages/core/src/actions.ts # packages/core/src/interpreter.ts # packages/core/src/types.ts # packages/core/test/interpreter.test.ts # packages/xstate-scxml/src/index.ts
# Conflicts: # packages/core/src/actions.ts
b387ec8
to
dd989c5
Compare
# Conflicts: # packages/xstate-react/src/useInterpret.ts
This PR deprecates the
send()
action creator in favor ofsendTo()
andraise()
.