File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -168,13 +168,14 @@ export const dataValidatorMachine = setup({
168
168
waiting : { } ,
169
169
debouncing : {
170
170
after : {
171
- debounceTimeout : '#validationMachine. validatingData'
171
+ debounceTimeout : '#validatingData'
172
172
}
173
173
}
174
174
}
175
175
} ,
176
176
177
177
validatingData : {
178
+ id : 'validatingData' ,
178
179
invoke : {
179
180
src : 'ValidateActor' ,
180
181
input : ( { context } : { context : ValidationMachineContext } ) => ( {
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ export const fromWorkerfiedActor = (
81
81
} ;
82
82
}
83
83
if ( event . type == WORKER_EVENTS . STATE_SNAPSHOT ) {
84
- const snapshot = ( event as STATE_SNAPSHOT_EVENT ) . data . snapshot ;
84
+ const snapshot = ( event as STATE_SNAPSHOT_EVENT ) . data . snapshot as AnyMachineSnapshot ;
85
85
return {
86
86
...state ,
87
87
...( snapshot || { } )
@@ -110,7 +110,7 @@ export const fromWorkerfiedActor = (
110
110
context : { } ,
111
111
matches : function ( value : StateValue ) {
112
112
const currentValue = ( this as WorkerSnapshot ) . value ;
113
- return matchesState ( currentValue , value ) ;
113
+ return matchesState ( value , currentValue ) ;
114
114
}
115
115
} as unknown as AnyMachineSnapshot ;
116
116
} ,
Original file line number Diff line number Diff line change @@ -37,7 +37,13 @@ const ProxyActor = setup({
37
37
38
38
const syncSnapshot = ( actorRef : AnyActorRef ) => {
39
39
return actorRef . subscribe ( ( snapshot ) => {
40
- postMessage ( workerEvents . stateSnapshot ( snapshot . toJSON ( ) ) ) ;
40
+ const jsonSnapshot = snapshot . toJSON ( ) ;
41
+ delete jsonSnapshot . children ; // children are not serializable
42
+ try {
43
+ postMessage ( workerEvents . stateSnapshot ( jsonSnapshot ) ) ;
44
+ } catch ( error ) {
45
+ console . error ( 'Error sending snapshot from worker' , error , jsonSnapshot ) ;
46
+ }
41
47
} ) ;
42
48
} ;
43
49
You can’t perform that action at this time.
0 commit comments