JSX Pragma for xstate #1842
Replies: 2 comments 7 replies
-
Just remember that there are some subtle differences between both formats - I see you have already handled some of them though, especially the fact that we need
It would be great if you could give a more concrete example of both types.
This is a really cool experiment! I believe though that this is somewhat out of the scope of the XState's core packages - but when this matures a little bit it could be linked to from the "Community" page (or similar). It's generally IMHO better to provide a single blessed way of doing something, otherwise, the community starts to diverge, people unnecessarily discuss which way is better, you start getting inconsistent articles on the internet etc.
Any more concrete example of this?
You can already use them - just using a callback actor. It might become a little bit easier in the v5 to create your own "to-actor" converters. There are already some changes regarding that on the
I'm afraid that parent-child relationships in JSX cannot be validated by TS. |
Beta Was this translation helpful? Give feedback.
-
Neat experiment! I wonder... could the JSX parent/child tag relationships be validated via custom ESLint rules? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am a big fan of your library and really appreciate the amount of work you've put into it. I feel lucky to be introduced to statecharts and SCXML through it. I read the SCXML docs while trying to learn the spec and how it diverges from XState's useful additions like actors, etc. During the course of that I started making a JSX pragma that mirrored the SCXML language to learn more about it.
JSX/Xstate is to SCXML, what JSX/React is to HTML. You can nest together states like React components. It's not any different than plain xstate in terms of functionality, I just find it really easier to read for some reason.
Here is one of the examples from your documentation:
The machine configs can be given in two ways:
or simply saying
<machine initial="green" config={configObj}>
My only real change besides syntax is having a separate "mutations" and "actions." This helps me mentally separate fire and forget actions and mutations easily just by looking at the code. It's not a deal breaker by any means, but a suggestion.
I have 4 main questions/areas of exploration at this point:
(1) Is this something you'd be interested in in a blessed xstate package, or should I continue on my own path?
(2) I hoped that using this syntax would unlock some interesting declarative patterns for composition. Like pre-hook React. I know pubsub and message passing is the preferred way of doing things here, but I thought it might help those in situations that call for a more tightly coupled implementation
(3) Is there any move to support async iterators in xstate? Or would such a PR be accepted? I think that would help
(4) I am a TS n00b. Would appreciate any advice on this aspect.
Thanks again for xstate :)
Beta Was this translation helpful? Give feedback.
All reactions