import Finity from '../../src';

const submachineConfig = Finity
  .configure()
    .initialState('substate1')
  .getConfig();

const stateMachine = Finity
  .configure()
    .initialState('state1')
      .on('event1').transitionTo('state2')
    .state('state2')
      .submachine(submachineConfig)
    .global()
      .onStateEnter(state => console.log(`Entering state '${state}'`))
  .start();

stateMachine.handle('event1');

@@ -36,78 +36,369 @@
 nst 
-submachineConfig = Finity%0A  .configure()%0A    .initialState('substate1'
+handleStateEnter = (state) =%3E console.log(%60Entering state '$%7Bstate%7D'%60);%0Aconst handleStateExit = (state) =%3E console.log(%60Exiting state '$%7Bstate%7D'%60);%0A%0Aconst submachineConfig = Finity%0A  .configure()%0A    .initialState('substate2A')%0A      .on('event2').transitionTo('substate2B')%0A    .global()%0A      .onStateEnter(handleStateEnter)%0A      .onStateExit(handleStateExit
 )%0A  
@@ -543,24 +543,67 @@
 e('state2')%0A
+      .on('event3').transitionTo('state3')%0A
       .subma
@@ -664,72 +664,108 @@
 ter(
-state =%3E console.log(%60Entering state '$%7Bstate%7D'%60))%0A  .start();%0A%0A
+handleStateEnter)%0A      .onStateExit(handleStateExit)%0A  .start();%0A%0Afor (let i = 1; i %3C= 3; i++) %7B%0A  
 stat
@@ -784,15 +784,20 @@
 dle(
-'
+%60
 event
-1'
+$%7Bi%7D%60
 );%0A
+%7D%0A

Update hierarchical state machine example