matthewp / robot

🤖 A functional, immutable Finite State Machine library

Home Page:https://thisrobot.life

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Does robot support multiple nested machines?

kybarg opened this issue · comments

const first = createMachine({
  start: state(
    transition('DONE', 'done'),
  ),
  done: state(),
})

const second = createMachine({
  start: state(
    transition('DONE', 'done'),
  ),
  done: state(),
})

const machine = createMachine({
  start: state(
    transition('FIRST', 'first'),
    transition('SECOND', 'second'),
  ),
  first: invoke(first,
    transition('done', 'start'),
  ),
  second: invoke(second,
    transition('done', 'start'),
  ),
})

when calling interpretedMachine.send('SECOND') get an error

uncaughtException TypeError: Cannot read property 'call' of undefined
    at Object.enter (\node_modules\robot3\dist\machine.js:90:13)
    at transitionTo (\node_modules\robot3\dist\machine.js:153:20)
    at send (\node_modules\robot3\dist\machine.js:164:12)
    at Object.send (\node_modules\robot3\dist\machine.js:171:20)

It should support them. I see that you closed it, did you discover what the issue was?