Fork me on GitHub
Adrian Aleixandre20:09:32

Hey folks! Spent the last few weeks diving into Fulcro in my evening hours. Awesome stuff! I have a question that I haven't been able to figure out on my own: I am wondering if it is possible to define a new state machine at runtime. I want to take a domain-specific data-structure (entered by a user) and convert it into a state machine that I can then run. Is this possible?


it should be possible


take a look at the definitions of uism/defstatemachine you'll see it adds the machine definition to a global registry key'd by a fully qualified symbol


so you'll have to do that yourself after building the machine (which is just a map)


and pass that machine definition into uism/begin!


now whether you really actually or should do that is a different matter


if you look at the source of RAD in com.fulcrologic.rad.form you'll see a state machine that works for an arbitrary form with all kinds of customization options


and @U0CKQ19AQ did not need to dynamically define that machine at runtime


but again, depends on your use case

Adrian Aleixandre21:09:27

Yeah that's a good point. I may be able to create a machine that directly uses my domain-specific data without actually creating a whole custom machine every time. Appreciate your detailed response!