Add capacity to pass bound variables for attribute map #8
Add capacity to pass bound variables for attribute map #8Sleepful wants to merge 5 commits intoroman01la:mainfrom
Conversation
|
I don’t like the vector syntax. Instead it should be possible to just provide props as usual and interpret them at runtime, this is how it’s done in all react wrappers |
|
UPDATE: I think I found a solution following the idea at the end of this comment, will push update soon. @roman01la I don't like the vector that much either. How could that be done? Right now the issue is that during compilation time, the bound attributes are indistinguishable from child nodes. Additionally, the child nodes are wrapped in a callback function. This means that at runtime, I have not found a way to differentiate between a bound attribute map and a child node. Do you see the problem that I see? wrap-children is the function that turns the args into a callback: Line 47 in 6300922 Perhaps an idea would be to leave the child-wrapping for runtime instead of compilation, that way the value type can be checked at runtime for something that indicates whether an attribute map is currently being passed. But I dunno, there might be better ways. What do you think? |
|
@roman01la updated :) LMK your thoughts! |
232f0c8 to
676da24
Compare
676da24 to
8ce2ad0
Compare
609570c to
b5ebb08
Compare
…the signals will be resolved to values (and thus lose its signal reference) before they can be captured by a wrap-component-props function
b5ebb08 to
031580b
Compare
In short, previously it was possible to pass an attribute map only by using the map literal, such as:
($ my-component {:class "this-is-literal"})this changes makes it such that the map can be passed as a variable, basically
($ my-component [my-attribute-map-variable])You will notice that I am wrapping the attribute map in a vector in order to hint the macro that the value is bound at runtime.
To understand this change better, please look at:
test/vitest/basic_component.cljca. The
(render #($ label-with-attrs [attrs] title input)line shows the usage, rather contrived.