Closed cassiozen closed 3 years ago
State might need to be a function to enable inference at individual state level. Maybe the API could look like this:
useStateMachine()({
initialState: 'inactive',
debugMode: true,
inactive: stateNode({
on: { TOGGLE: 'active' },
}),
active: stateNode({
on: { TOGGLE: 'inactive' },
effect() {
console.log('Just entered the Active state');
},
}),
}
});
Working TS Sample with type narrowing on both send
functions: typescript playground
Solved by #11
The "send" function argument type should be an union of transition names. It works properly in the send method returned by useStateMachine - but the send method passed to effect currently broadens to "string".