I’ve just released a functional statecharts library for Clojure and ClojureScript. Documentation is missing at the moment, but there are over 100 tests you can consult to check the functionality. Semantics are based on the SCXML standard https://github.com/retro/state-machete
What's your major use case for inventing this lib? I've also created a clj/cljs statecharts library for better state management in re-frame apps and some custom script https://github.com/lucywang000/clj-statecharts
@wxitb2017 I didn’t know about your lib, I’ll definitely check your implementation! As for the usecase, I’ve started working on it last year as part of the research for https://github.com/keechma/keechma-next (In the end I’ve went with a different approach for keechma/next), but I’ve never finished it. I’m starting some work on a backend system that needs to have a pretty flexible business logic, so I’m planning to use statecharts + https://github.com/agentbellnorm/dativity (or an approach similar to it) to implement it.
I wanted to implement statecharts as a pure function without internal state to ensure I can use it in any context I need (and provide my own persistence on top of it). This was inspired by the https://github.com/cark/cark.behavior-tree library
Cool. You could also take a look the most popular js statecharts lib xstate (if not yet) https://github.com/davidkpiano/xstate , my lib borrowed most of the design from it.
Yeah, I’ve used XState previously and it’s a great library, but in the end I went with an implementation that’s closer to the SCXML standard because SCION project has a great test suite (https://gitlab.com/scion-scxml/test-framework) which I was able to port, and it ensured that the algorithm is correct for more complex transitions
Great to know these projects like dativity, lots of food for thought! > implementation that’s closer to the SCXML standard because SCION project has a great test suite XState doesn't use scxml-like syntax but this doesn't prevent it to https://github.com/davidkpiano/xstate/blob/3dcf91861964f0e3c581b08fcb3357f658b75bea/packages/core/test/scxml.test.ts. My lib doesn't put conforming to SCXML as a top priority, but focus mostly on what I need in real world projects. For example I need delayed transitions, eventless transitions (transient states), first-class re-frame integration, so I implemented these features. OTOH so far I don't see any need for history states, so I just leave it out.
Just created the #statecharts channel so people interested could talk there
The re-frame integration looks really interesting, especially the epoch support. Thanks!
really interesting links in here, thanks for the inspo! :thumbsup:
Clojure tools 1.10.1.716 is now available: • Make edn reading tolerant of unknown tagged literals • Update to latest dependencies for maven-resolver and aws-api