Hi - is there a way I can make the options going into defsc dynamic?
There is a bit more going on but the core idea is to try to build up a :componentDidMount method using external data that lends itself to being abstracted into a separate method call
Normally you would add this to the options map sent to defsc
(defsc NewComponent [this props] {:componentDidMount (fn [this] ...) } ())
I thought I might be able to separate this out into its own declaration
(def myoptions {:componentDidMount (fn [this] ...)})
(defsc NewComponent [this props] myoptions ())
but this doesn't work - neither did trying to use a custom macro
I dug around in the defsc code and found that the issue centres around the call to s/conform
(s/conform ::args args)
That is, that anything that isn't specifically declared as a map in the args when calling defsc is grouped into the "body" key
Is there something I'm missing - is there a way to "fool" the spec library to see the declared map as a map and not a symbol / method call?
I tried using a macro but I'm not sure at what point it's being expanded at compile time and if this is before or after the defsc macro is expanded and whether or not that would make any difference anyway...
Another route might be to "extend" or "wrap" the defsc macro to create the desired functionality but I'm unsure how to start doing that.
It may be that a wider rethink is needed but hopefully you agree with me that it's interesting to explore the options of customising Fulcro and where the boundaries for this lie.
Thanks
There an sc function. Use that as the basis for your own macro or wrapper function. Defsc does what it does to get better compile time error checking. It's generally not a good idea for a macro to eval an expression for many reasons at compile time.