rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
sova-soars-the-sora 2017-11-18T02:15:37.000032Z

@jfntn https://github.com/tonsky/rum#components-local-state

sova-soars-the-sora 2017-11-18T02:15:57.000009Z

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-sora 2017-11-18T02:17:13.000063Z

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

jfntn 2017-11-18T15:16:30.000069Z

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

sova-soars-the-sora 2017-11-18T16:23:53.000056Z

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

sova-soars-the-sora 2017-11-18T16:30:08.000029Z

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

2017-11-18T16:34:14.000087Z

There are no static props in Rum

2017-11-18T16:35:05.000002Z

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

jfntn 2017-11-18T16:50:59.000005Z

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

jfntn 2017-11-18T16:52:50.000036Z

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

jfntn 2017-11-18T16:53:23.000040Z

I’m not sure mixins would allow that?

sova-soars-the-sora 2017-11-18T17:13:42.000099Z

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-sora 2017-11-18T17:16:02.000016Z

there is probably a clever way, though!

sova-soars-the-sora 2017-11-18T17:16:03.000026Z

🙂

rauh 2017-11-18T17:39:24.000029Z

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

rauh 2017-11-18T17:40:35.000014Z

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

rauh 2017-11-18T17:41:12.000045Z

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

2017-11-18T18:02:59.000010Z

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

2017-11-18T18:03:03.000035Z

maybe try that?

jfntn 2017-11-18T18:08:18.000022Z

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

sova-soars-the-sora 2017-11-18T18:17:47.000062Z

Ah, for serverside rendering!

sova-soars-the-sora 2017-11-18T18:30:35.000040Z

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-sora 2017-11-18T18:37:27.000069Z

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

sova-soars-the-sora 2017-11-18T19:24:26.000099Z

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

jfntn 2017-11-18T20:41:54.000045Z

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

jfntn 2017-11-18T20:42:01.000018Z

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

jfntn 2017-11-18T21:03:41.000038Z

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

jfntn 2017-11-18T21:04:10.000067Z

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

sova-soars-the-sora 2017-11-18T21:22:05.000023Z

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

sova-soars-the-sora 2017-11-18T21:34:52.000045Z

(js/document.getElementById "f9") ?

sova-soars-the-sora 2017-11-18T21:38:02.000061Z

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

sova-soars-the-sora 2017-11-18T21:38:39.000031Z

@jfntn you can use cljs/clj conditional lines

sova-soars-the-sora 2017-11-18T21:38:50.000071Z

have you seen those around?

sova-soars-the-sora 2017-11-18T21:39:16.000036Z

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-sora 2017-11-18T21:51:13.000085Z

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

2017-11-18T22:26:35.000119Z

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

2017-11-18T22:28:08.000057Z

@sova

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