@@ -9,6 +9,11 @@ interface TutorialConfig {
99 testRunner : G . EnumTestRunner
1010}
1111
12+ interface PositionProgress {
13+ position : CR . Position
14+ progress : CR . Progress
15+ }
16+
1217export interface TutorialModel {
1318 repo : G . TutorialRepo
1419 config : TutorialConfig
@@ -20,9 +25,10 @@ export interface TutorialModel {
2025 level ( levelId ?: string ) : G . Level
2126 stage ( stageId ?: string ) : G . Stage
2227 step ( stepId ?: string ) : G . Step
23- updateProgress ( ) : { position : CR . Position , progress : CR . Progress }
28+ updateProgress ( ) : PositionProgress
2429 nextPosition ( ) : CR . Position
2530 hasExisting ( ) : Promise < boolean >
31+ setClientDispatch ( editorDispatch : CR . EditorDispatch ) : void
2632}
2733
2834class Tutorial implements TutorialModel {
@@ -31,9 +37,13 @@ class Tutorial implements TutorialModel {
3137 public version : G . TutorialVersion
3238 public position : CR . Position
3339 public progress : CR . Progress
40+ private clientDispatch : ( props : PositionProgress ) => void
3441
3542 constructor ( ) {
3643 // initialize types, will be assigned when tutorial is selected
44+ this . clientDispatch = ( props : PositionProgress ) => {
45+ throw new Error ( 'Tutorial client dispatch yet initialized' )
46+ }
3747 this . repo = { } as G . TutorialRepo
3848 this . config = { } as TutorialConfig
3949 this . version = { } as G . TutorialVersion
@@ -51,6 +61,10 @@ class Tutorial implements TutorialModel {
5161
5262 }
5363
64+ public setClientDispatch ( editorDispatch : CR . EditorDispatch ) {
65+ this . clientDispatch = ( { progress, position} : PositionProgress ) => editorDispatch ( 'SEND_DATA' , { progress, position} )
66+ }
67+
5468 public init = ( tutorial : G . Tutorial ) => {
5569 this . repo = tutorial . repo
5670 this . config = {
@@ -73,6 +87,11 @@ class Tutorial implements TutorialModel {
7387 complete : false ,
7488 }
7589
90+ this . clientDispatch ( {
91+ position : this . position ,
92+ progress : this . progress
93+ } )
94+
7695 // set tutorial, position, progress locally
7796 // TODO: base position off of progress
7897 Promise . all ( [
0 commit comments