Is there any particular reason Machine is not a constructor? The fact that it's capitalized but not actually a constructor means that I have to work around lint rules and style guidelines and litter my code with eslint comments to use it with the rest of my code or else turn off the useful lint warnings.
import { Machine, interpret } from 'xstate';
// eslint-disable-next-line new-cap
const machine = Machine({...});
If it's just a personal preference that you want to be different than 99% of JS code that's totally fine but I thought I'd ask if maybe there was some more concrete reason like maybe this is ES8 style or something new I'm not aware of.
Thanks
Nothing's stopping you from having const machine = new Machine(...); it'll work.
It's just a convention that Machine(...) returns a machine object that is "static" - it never changes its internal state.
However, I can/will add createMachine as an alias to the API:
import { createMachine } from 'xstate';
const machine = createMachine(...);
Better?
createMachine is much better 馃憤
The createMachine function is now in xstate@next.
Most helpful comment
Nothing's stopping you from having
const machine = new Machine(...); it'll work.It's just a convention that
Machine(...)returns a machine object that is "static" - it never changes its internal state.However, I can/will add
createMachineas an alias to the API:Better?