-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hello and thank you for this library.
Have you considered providing a method to check if a transition may be traversed (i.e. exists and would pass the guards) without changing the current state, such as the XState can method?
I found that I do something like:
const machine = createMachine(
{ idle: state(transition("start", "started", isReady)},
// ...
);
function Widget() {
const [current, send] = useMachine(machine);
const disabled = current.value.transitions.get("start")[0].guards(current.context)
return <button onClick={() => send('start")} disabled={disabled} >Start</button>
}
but a little awkward. Maybe something like
current.value.transitions.get("start").may() // => boolean
would be helpful (assumption: guards are pure functions). Maybe there is already a better way?
ehuelsmann and andreylysenko
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request