This repository was archived by the owner on Mar 4, 2022. It is now read-only.
Description The following example
import { createMachine , MachineConfig } from "xstate" ;
type Context = { name : string } ;
type Event = { type : "CHANGE_NAME" ; name : string } ;
const config : MachineConfig < Context , any , Event > = {
states : {
a : { always : { target : "b" } } ,
b : { type : "final" } ,
} ,
} ;
const machine = createMachine < Context , Event > ( {
initial : "A" ,
states : {
A : { ...config } ,
B : { ...config , states : { ...config . states , c : { } } } ,
} ,
} ) ;
parses to
[
{
"initial" : "A" ,
"states" : {
"A" : {
"states" : {
"a" : {
"always" : {
"target" : "b"
}
} ,
"b" : {
"type" : "final"
}
}
} ,
"B" : {
"states" : {
"c" : { }
}
}
}
}
]
instead of
[
{
"initial" : "A" ,
"states" : {
"A" : {
"states" : {
"a" : {
"always" : {
"target" : "b"
}
} ,
"b" : {
"type" : "final"
}
}
} ,
"B" : {
"states" : {
"a" : {
"always" : {
"target" : "b"
}
} ,
"b" : {
"type" : "final"
} ,
"c" : { }
}
}
}
}
] Reactions are currently unavailable
The following example
parses to
instead of