Skip to content

Commit

Permalink
Fixed an issue with not being able to run XState in a web-worker (#1407)
Browse files Browse the repository at this point in the history
* allow running xstate in a web-worker

* Update .changeset/nervous-shoes-retire.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

* use self instead of window to simplify the code

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
tomenden and Andarist committed Aug 26, 2020
1 parent 34a3097 commit ad3026d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nervous-shoes-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

Fixed an issue with not being able to run XState in Web Workers due to assuming that `window` or `global` object is available in the executing environment, but none of those are actually available in the Web Workers context.
2 changes: 1 addition & 1 deletion packages/core/src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class Interpreter<
},
logger: global.console.log.bind(console),
devTools: false
}))(typeof window === 'undefined' ? global : window);
}))(typeof self !== 'undefined' ? self : global);
/**
* The current state of the interpreted machine.
*/
Expand Down

0 comments on commit ad3026d

Please sign in to comment.