trexitycode / wirestate

MIT License
1 stars 0 forks source link

Discussion: default machine #8

Open matb33 opened 5 years ago

matb33 commented 5 years ago

We should discuss the return value of the generate wirestate function. For example, Alex's visualizer needs a predictable way to choose a machine to render. In app use it's easy, we can do e.g. machines['App']. But for the visualizer, it's a bit trickier. We're going with a hardcoded 'Main' machine name as the default for now. Would be great to have a proper way of doing this.

We had this idea that perhaps we could hint which one is the main one:

@machine App*

Leverage the "initial state" qualifier to signify it's the "initial machine".

Not sure what that does to the return value of wirestate though.

dschnare commented 5 years ago

I like that idea. We could perhaps set the initial machine as the $initial property:

const machines = wirestate(...)
const App = machines['App']
const AppAsWell = machines.$initial // first machine if none is tagged as initial?
matb33 commented 5 years ago

That's a great idea. Perfect!