-
-
Notifications
You must be signed in to change notification settings - Fork 63
Events in sidebar not working for drag and drop, pagination and offline queue machines #15
Comments
I think the current Also, trying to reproduce this issue I noticed that the issue you highlighted above occurs in the visualiser (when clicking on events), regardless of whether |
Yes exactly So we would need to display an event more than once in the sidebar, because it can be parametrized. It could look like And regarding the visualizer, yes you are completely right. The visualizer knows nothing about Although the Debounce Statechart is a special case here. See: #14 |
Oh yes of course, this is going in the right direction. I love the wording more imaginative! 😁 If we get access to the event's type information we could render a form based on the parameters needed to create a sendable event. So for primitive types we could automatically render form input fields and everything more complex could fall back to a JSON Input as can be seen in David's inspector. Maybe this idea is over-engineering this problem for now, but in my opinion it could make an awesome tool for explorative testing of Statecharts that are a little bit more complex. |
@bemayr that's a neat idea; leveraging types is always satisfying! Note however that neither the form nor the JSON input will work for functions (e.g. A simpler but perhaps sufficient alternative would be to allow for multiple event payloads to be defined, each identified by a name (i.e. "variants" of events). Then when clicking on an event you could select the payload you want to send (with a dropdown). |
This makes me wonder whether it's reasonable at all to have functions as part of event payloads. I am not too familiar with xstate "best practices"; is there a recommendation / requirement that events are serialisable? c.f. #14 (comment) |
Came to the same conclusion and started #14 because of that. |
@bemayr I think we should be more explicit with the event payloads. This auto-generation of event payloads from the schema is in the works - you can actually define your events using JSON Schema as of 4.17.0. I know David is thinking about this a lot for the visual builder - autogenerating events will probably be a first class citizen in the future. https://github.com/davidkpiano/xstate/releases/tag/xstate%404.17.0 This project isn't the space for this sort of innovation, though - because it's a learning resource, we should be more transparent and less magical with how we declare event payloads. @hmaurer As far as I know, there's no requirement for event payloads to be JSON-serialisable in the same way as, say, Redux recommends. I do like the idea of variants of events - though this may end up being less useful than a small form where a user can define any payload of an event themselves. |
Ah yes, I completely get that - thanks for the detailed explanation! Then I totally ship the idea of the small form, because as you said in this project it does not have to be fully generic and more transparency yields a better learning effect! And regarding the JSON serializability I am afraid to tell you that it is like in redux: #14 (comment) |
Regarding the idea of small forms and the mention of JSON Schema in [email protected], I came across this project recently which might be of interest: https://github.com/rjsf-team/react-jsonschema-form |
These are sweet ideas, and we can probably initiate a discussion about them on the discussions section. I've already got some nice designs fizzing around in my head. What was the original scope of this issue? That the sidebar event payloads don't work? @bemayr |
It originated out of #13 where I was unable to fix it for all the machines. So I fixed it for all possible ones with #16. Shall we open a new issue for those (to keep track) and close this one? Looking forward to your design ideas! |
Let's rename this one, so that we keep the context above. |
eventPayloads
in Drag and Drop Machine
While working in #13 I stumbled upon a problem with the current
eventPayloads
implementation.The events in this Statechart are parametrized with the respective
index
that is either dragged (PICK_UP
) or reaches an intersection (DRAG_REACHED_INTERSECTION
). This works pretty well here:but sadly does not work in the Sidebar. (because of the way events are distinct by their name only)
Result
The interactive documentation is one of the best features I have seen lately, maybe we can find a way with great UX to provide an event's payload, or David is already working/has already done this (😉). 🚀
Affected Machines
edits:
The text was updated successfully, but these errors were encountered: