Fork me on GitHub
Michael W01:03:33

I have been trying to wrap my head around the fulcro statecharts library. I decided to try to model something really simple, a board for the game tic-tac-toe. I thought the easiest way to model it would be as 9 cells that can be O, X, or nil. I have the statechart setup, and am not understanding what I'm seeing. I have it running, but it does not transition between the states as I expect. I tried to use the traffic lights example to puzzle out how to make the transitions, but I think I am not understanding something fundamental. I have a small repo with a scratch project here that shows my statechart: I am not sure where to go from here in order to troubleshoot this, I have done quite a bit of reading on the scxml docs, as well as looking at the examples in the fulcro statecharts source, and playing around with it at the repl. I hoped a simple 3-way state chart would be easy enough to build that I could grasp the concepts without the complexity of the traffic-lights example.

Michael W03:03:07

I have it almost working, I can transition between 3 states, but I think it's really 2 different toggles instead of a 3 way state. I would like a cell to be empty-or-O or empty-or-X and i can't figure out how to model that in the chart. Any pointers would be appreciated.

Michael W03:03:16

Almost have this working now, just still figuring out data access. @U0CKQ19AQ I created some simple examples while playing around with the statecharts library, would you accept a PR to add them to your examples dir in fulcrologic/statecharts? I plan to add more once I figure out how to get data into the charts.


Did you see the install command? Once you've installed the state chart support into fulcro itself, you don't need to mess with processing the event yourself, since there's an event queue built in, etc. Your example seem to imply that you're using it outside of fulcro?

Michael W04:03:46

I'm actually using it stand-alone outside of fulcro.


Ok. So then you're examples would not really belong with the fulcro integration parts. The state charts are a separate thing, so when you mention fulcro it makes me think that you've misunderstood something. There happens to be a namespace for integrating with my other library, but the state chart support itself is meant to be just standalone. In that sense, I don't feel like your examples are interesting enough to actually include. They might be a good thing to use as part of some sort of beginners introductory blog post or something.


It's hard to justify the use of a state chart for a simple boolean, or a Tri-State flag

Michael W04:03:58

I don't really blog and trying to work from the simplest to more complex made it easier for me to build up to the more complex game.


In my opinion, the best reference if you're willing to read it, is the original paper on state charts from the 1980s. It's freely available in pdf, and is accessible to almost any reader with the willpower to read it


Of course the scxml standard deviates a bit from the original ideas, but it's similar enough to get the point

Michael W05:03:33

I put the wrong repo name in my comment, fixed, you have examples in the statecharts src dir for traffic signals, invokations, etc.

Michael W05:03:45

I'll take a look at that paper, thanks.