Fork me on GitHub
#rum
<
2017-11-18
>
sova-soars-the-sora02:11:57

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).

sova-soars-the-sora02:11:13

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

jfntn15:11:30

Thanks we spotted that, but we want to get that data without instantiating the component, like om.next’s static methods

sova-soars-the-sora16:11:53

@jfntn what's the static equivalent in om.next? the dereferenced atom value?

sova-soars-the-sora16:11:08

I don't know if I get what you need, but maybe I can help, since I am doing some rum today (=

Niki16:11:14

There are no static props in Rum

Niki16:11:05

How do you get an instance of a component class? Where do you need this data?

jfntn16:11:59

I’m looking for an implementation strategy for something similar to om.next’s collocated queries

jfntn16:11:50

We’d like to somehow “annotate” the component with its query, and retrieve that query without having to mount the component first

jfntn16:11:23

I’m not sure mixins would allow that?

sova-soars-the-sora17:11:42

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

sova-soars-the-sora17:11:02

there is probably a clever way, though!

rauh17:11:24

@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)

rauh17:11:35

(defn fooooo [])
(specify! fooooo
  IDeref
  (-deref [f] "foo"))
@fooooo

rauh17:11:12

So just create a protocol and attach it to the function, then write some macros to get a nice DSL.

Niki18:11:59

if I remember correctly we actually let you specify meta on fn and carry it on into the resulting component

Niki18:11:03

maybe try that?

jfntn18:11:18

Meta sounds best because we’d like this to work with SSR, I’ll try that and report back

sova-soars-the-sora18:11:47

Ah, for serverside rendering!

sova-soars-the-sora18:11:35

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.

sova-soars-the-sora18:11:27

@jfntn please keep us posted on what you choose to do

sova-soars-the-sora19:11:26

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...

jfntn20:11:54

@tonsky unfortunately it looks like defc and defcs don’t preserve the meta set on the name

jfntn20:11:01

(rum/defcs ^{:foo :bar} label [] [:div])
(meta label)                            ;; => nil

jfntn21:11:41

ah my bad, (meta #'label) works!

jfntn21:11:10

that’s in clj though, not sure if cljs will work the same?

sova-soars-the-sora21:11:05

how do I mount to a div that is not document.body ?

sova-soars-the-sora21:11:52

(js/document.getElementById "f9") ?

sova-soars-the-sora21:11:02

my cljs is a bit rusty xD but that did work.

sova-soars-the-sora21:11:39

@jfntn you can use cljs/clj conditional lines

sova-soars-the-sora21:11:50

have you seen those around?

sova-soars-the-sora21:11:16

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"

sova-soars-the-sora21:11:13

How do you nest components in rum? Like "big component has 9 tiny components inside" ?

Niki22:11:35

@jfntn I remember there has been some work to support meta on vars in cljs. Not sure the status

Niki22:11:08

@sova

(rum/defc big-comp []
  [:div
    (small-comp) (small-comp) (small-comp)])