-
-
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
allow running xstate in a web-worker #1407
Conversation
🦋 Changeset is good to goLatest commit: c02ccbd We got this. 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 |
I think this means I probably messed up the changeset, right? I did not mean to create any major releases. |
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. Latest deployment of this branch, based on commit c02ccbd:
|
I could not find anywhere in xstate docs what Node.js version it is aimed for. |
packages/core/src/interpreter.ts
Outdated
@@ -124,7 +124,13 @@ export class Interpreter< | |||
}, | |||
logger: global.console.log.bind(console), | |||
devTools: false | |||
}))(typeof window === 'undefined' ? global : window); | |||
}))( | |||
typeof window !== 'undefined' |
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 could just use self
over window
as window.self
is supported in all popular browsers
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.
Done
Can't do that right now due to the fact that (like you have mentioned) this would be a breaking change. |
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.
Great change; see @Andarist's suggestions; other than that, LGTM!
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@Andarist Updated the PR. |
Currently, the code of the interpreter assumes that the code runs either in the browser's main thread (
window
is defined) or in node. This PR allows it to run in a web-worker, in which the global isself