specifically #3: rum.core/defcs is used instead of rum.core/defc. It allows you to get hold of the components’s state in the render function (it will be passed as a first argument).
I am pretty certain you need to instantiate the component for this to be available, but i am but a newbie and you should really ask @tonsky
Thanks we spotted that, but we want to get that data without instantiating the component, like om.next’s static methods
@jfntn what's the static equivalent in om.next? the dereferenced atom value?
I don't know if I get what you need, but maybe I can help, since I am doing some rum today (=
There are no static props in Rum
How do you get an instance of a component class? Where do you need this data?
I’m looking for an implementation strategy for something similar to om.next’s collocated queries
We’d like to somehow “annotate” the component with its query, and retrieve that query without having to mount the component first
I’m not sure mixins would allow that?
not mixins, but you could maintain a UI tree in parallel, these 2 concepts are smashed together in om.next... maintaining yet another structure in parallel sounds like an easy way to overcomplicate way down the line
there is probably a clever way, though!
🙂
@jfntn Note: You can store whatever you want in a Javascript function, this is how many of the CLJS concepts are realized (variadic functions, multi arity fns)
(defn fooooo [])
(specify! fooooo
IDeref
(-deref [f] "foo"))
@fooooo
So just create a protocol and attach it to the function, then write some macros to get a nice DSL.
if I remember correctly we actually let you specify meta on fn and carry it on into the resulting component
maybe try that?
Meta sounds best because we’d like this to work with SSR, I’ll try that and report back
Ah, for serverside rendering!
That makes sense. Yes, you'd want to keep something addressable in play before components are initialized. That data must come from somewhere, I wonder what the nicest way to integrate it is.
@jfntn please keep us posted on what you choose to do
I have a question, is the typical refresh loop timer set to 1 second ? (1000 ms) and ... do you guys tweak this? i'm curious about long-term browser cpu usage, maybe it's not a real concern, i did some profiling in the browser and it seems all righty...
@tonsky unfortunately it looks like defc
and defcs
don’t preserve the meta set on the name
(rum/defcs ^{:foo :bar} label [] [:div])
(meta label) ;; => nil
ah my bad, (meta #'label)
works!
that’s in clj though, not sure if cljs will work the same?
how do I mount to a div that is not document.body ?
(js/document.getElementById "f9") ?
my cljs is a bit rusty xD but that did work.
@jfntn you can use cljs/clj conditional lines
have you seen those around?
so in your serverside code you can have the "do this if it's we're in a clj world, this other line if we're in cljs land"
How do you nest components in rum? Like "big component has 9 tiny components inside" ?
@jfntn I remember there has been some work to support meta on vars in cljs. Not sure the status
(rum/defc big-comp []
[:div
(small-comp) (small-comp) (small-comp)])