Fork me on GitHub
#fulcro
<
2020-09-26
>
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?

3
currentoor20:09:05

it should be possible

currentoor20:09:55

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

currentoor20:09:04

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

currentoor20:09:37

and pass that machine definition into uism/begin!

currentoor20:09:10

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

currentoor20:09:00

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

currentoor20:09:19

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

currentoor20:09:54

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!