Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Feature Request: Allow users to specify return value of guard #305

Open
jonroby opened this issue Oct 27, 2021 · 3 comments
Open

Feature Request: Allow users to specify return value of guard #305

jonroby opened this issue Oct 27, 2021 · 3 comments

Comments

@jonroby
Copy link

jonroby commented Oct 27, 2021

When using the visualizer, if a guard is left unimplemented as a string, users can't move between states.

As a developer (or product designer), I would like to specify the return value of a guard in the visualizer, so that I can explore the state chart by clicking on different scenarios, without having to implement the functions. In the code, developers could just use a placeholder string: { ..., cond: "myCond" }.

@codingedgar
Copy link

codingedgar commented Feb 17, 2022

This discussion is also evaluated here statecharts/xstate-viz#31 (comment) but I'm guessing this is the main repo now?

My own comment in that other repo was:

If I chick a transition, shouldn't that mean the guard is returning true? otherwise, I would click the other transition, right? At least for the click scenario, I see the guarded transitions as two distinct transitions, I'm guessing that's not what is happening.

I'm using the viz in vscode, and there's no way (i think) to send a specific event with payload, but regardless I just want to play with the machine with clicks to make videos, as a simulation where the truth is what I click. Also for other non-tech team members, it is super useful, just an interactive diagram of what is happening based on the machine definition with strings.

I'm not sure if it is a bug, but sometimes I click a guarded transition and it takes me to another event state node that shouldn't (as if I had selected a different guarded outcome) and sometimes if I restart it works as expected, but other times it is evaluating just the same outcome from a guarded transition, and I cannot transition to certain event state node ever because the guarded transition just does not go there, it keeps choosing another scenario.

@mattpocock
Copy link
Contributor

@codingedgar Correct, that old one should be disposed of (cc @davidkpiano)

In the visual editor, we wrote code for this exact purpose - being able to simulate a state machine without needing to run side effects in guards. I think, at some point, we may make this runner available as an alternate in the viz.

@codingedgar
Copy link

codingedgar commented Feb 17, 2022

@codingedgar Correct, that old one should be disposed of (cc @davidkpiano)

In the visual editor, we wrote code for this exact purpose - being able to simulate a state machine without needing to run side effects in guards. I think, at some point, we may make this runner available as an alternate in the viz.

I noticed it! That was a super good idea.

Right now the visual editor does not allow me to make it look pretty (I cannot move lines or auto-organise like viz) and presentable to clients or other team members, so i wonder what could happen first, the editor looking as pretty as the viz or the viz integrating other ways of simulation. Can I contribute in some way?

(Also, the old repo has a note on the readme but probably archiving to read only would be best)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants