Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22eb2c9

Browse files
committed
setup state string for debugging
1 parentda29192 commit22eb2c9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎src/state/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ import createMachine from './machine'
55
// machine interpreter
66
// https://xstate.js.org/docs/guides/interpretation.html
77

8+
// convert state into a readable string
9+
conststateToString=(state:string|object,str:string=''):string=>{
10+
if(typeofstate==='object'){
11+
constkeys=Object.keys(state)
12+
if(keys&&keys.length){
13+
constkey=keys[0]
14+
returnstateToString(state[key],str.length ?`${str}.${key}` :key)
15+
}
16+
returnstr
17+
}elseif(typeofstate==='string'){
18+
returnstate
19+
}
20+
return''
21+
}
22+
823
interfaceProps{
924
dispatch:CR.EditorDispatch
1025
}
@@ -23,10 +38,8 @@ class StateMachine {
2338
this.service=interpret(machine,this.machineOptions)
2439
// logging
2540
.onTransition(state=>{
26-
// console.log('onTransition', state)
2741
if(state.changed){
28-
// console.log('next state')
29-
// console.log(state.value)
42+
console.log(`STATE:${stateToString(state.value)}`)
3043
dispatch('coderoad.send_state',{state:state.value,data:state.context})
3144
}else{
3245
dispatch('coderoad.send_data',{data:state.context})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp