11import * as CR from 'typings'
2- import { assign , Machine , MachineOptions , actions } from 'xstate'
2+ import { assign , Machine , MachineOptions } from 'xstate'
33import editorActions from './actions/editor'
44import commandActions from './actions/command'
55import contextActions from './actions/context'
@@ -72,18 +72,18 @@ export const createMachine = (options: any) => {
7272 } ,
7373 SelectTutorial : {
7474 onEntry : [ 'clearStorage' ] ,
75- id : 'start -new-tutorial' ,
75+ id : 'select -new-tutorial' ,
7676 on : {
7777 SELECT_TUTORIAL : {
78- target : 'LoadTutorial ' ,
78+ target : 'LoadTutorialSummary ' ,
7979 actions : [ 'newTutorial' ] ,
8080 } ,
8181 } ,
8282 } ,
8383 // TODO move Initialize into New Tutorial setup
84- LoadTutorial : {
84+ LoadTutorialSummary : {
8585 invoke : {
86- src : services . loadTutorial ,
86+ src : services . loadTutorialSummary ,
8787 onDone : {
8888 target : 'Summary' ,
8989 actions : assign ( {
@@ -102,9 +102,31 @@ export const createMachine = (options: any) => {
102102 on : {
103103 BACK : 'SelectTutorial' ,
104104 TUTORIAL_START : {
105- target : '#tutorial' ,
106- actions : [ 'initPosition' , 'initTutorial' ] ,
105+ target : 'LoadTutorialData' ,
106+ } ,
107+ } ,
108+ } ,
109+ LoadTutorialData : {
110+ invoke : {
111+ src : services . loadTutorialData ,
112+ onDone : {
113+ target : 'SetupNewTutorial' ,
114+ actions : assign ( {
115+ tutorial : ( context , event ) => event . data ,
116+ } ) ,
107117 } ,
118+ onError : {
119+ target : 'Error' ,
120+ actions : assign ( {
121+ error : ( context , event ) => event . data ,
122+ } ) ,
123+ } ,
124+ } ,
125+ } ,
126+ SetupNewTutorial : {
127+ onEntry : [ 'configureNewTutorial' , 'initPosition' ] ,
128+ after : {
129+ 0 : '#tutorial' ,
108130 } ,
109131 } ,
110132 ContinueTutorial : {
@@ -224,7 +246,7 @@ export const createMachine = (options: any) => {
224246 onEntry : [ 'userTutorialComplete' ] ,
225247 on : {
226248 SELECT_TUTORIAL : {
227- target : '#start -new-tutorial' ,
249+ target : '#select -new-tutorial' ,
228250 actions : [ 'reset' ] ,
229251 } ,
230252 } ,
0 commit comments