Hi, i have a question about the dynamic creation of sessions: as I understand from the docs, mk-session doesn’t work for cljs, because the rule compilation is done at macro compile time. But it’s not clear to me if the macro compiling is only referring to the defrules and namespaces, or also “deeper”. Specifically, is it possible to dynamically create a session in clojurescript if the rules are provided already in the output form of the defrule macro, so with the explicit :lhs and :rhs in a map?
My usecase is the following: I promised my customer to allow for dynamic addition of (simple) rules through a web interface. Those rules would be used together with pre-defined rules in another web app. Of course I can run the rule execution on the backend and communicate between front-and-backend, but running it on the frontend would be more elegant…
If it’s not possible, a follow-up: would it work to do the dynamic (re)compilation on the backend, and then serialize the session in fressian, send it to the frontend and unpack and use it there?
@mathias_dw the session must be compiled in clj space. It is compiled to data structure but also has Forms that need to be compiled by the cljs compiler - such as functions
So the cljs compiler must Pre compile all of the session structure resulting in JS
That JS would evaluate on client. You can’t dynamically alter it all in JS
It’d require having the whole cljs compiler available in the JS. Which is possible. But not the usual setup for a web app
And even the. Would require Clara to support self hosting. Which I don’t think it may fully do yet
I have been working (slowly) on a big overhaul of the mechanics of how cljs is compiled in Clara. But it doesn’t change above.
Serialization as freesian won’t work though
It’s not a “pure data structure”
ie. Has things like functions. And possibly closures etc. Could try serializing fn’s but that’s a whole other problem space and has it's limits
@mathias_dw maybe the competition helps https://github.com/oakes/odoyle-rules
Thanks a lot, guys! I'll just run it on the backend then. I did see odoyle rules, but I definitely want truth maintenance.
Seems perhaps odoyle is too different to be true “competition”
Or should there be one rules engine to rule them all? 😛