Fork me on GitHub
#reagent
<
2018-07-29
>
henrik04:07:55

I’ve SSR’d re-frame just fine on NodeJS. I had a whack at nashorn once, but it was horribly hard to get right.

henrik04:07:06

Since I’m exploring Ions at the moment, I’ve gone with Rum for now, for SSR. On Ions, there’s no way to run nodejs that I’m aware of.

Bravi15:07:28

hi everyone. is there a reason why on-drag-end wouldn’t work unless I don’t drag over different items? basically if I just click on an item and if I don’t change the position at all, then it fires

Bravi15:07:39

if I change the position, it doesn’t fire

rnagpal19:07:57

If I create a ratom and then refer it in the component, now when I reset the value of the atom, how internally does reagent figure out which component is derefing that atom and refresh it ?

rnagpal19:07:04

I am looking at the source code, but could not figure this out

justinlee19:07:10

@rnagpal reagent sets a dynamically bound variable before running the render function. the implementation of ratom/dereflooks at that variable and adds the component to the watch list

rnagpal19:07:10

(defn- notify-deref-watcher! [derefed]
  (when-some [r *ratom-context*]
    (let [c (.-captured r)]
      (if (nil? c)
        (set! (.-captured r) (array derefed))
        (.push c derefed)))))

rnagpal19:07:48

derefed is the atom or the component ?

rnagpal19:07:08

IDeref
  (-deref [this]
    (notify-deref-watcher! this)
    state)

justinlee19:07:32

I think c is the component and derefed is the atom. the nil-check is to see if this component has already derefed other atoms, and if not, create an array of atoms

rnagpal19:07:20

(set! (.-captured r) (array derefed)) if nil this is executed

justinlee19:07:20

the code is crazy confusing because it does all this caching by setting properties on itself

rnagpal19:07:47

so seems like derefed is component

justinlee19:07:51

right: it creates an array of the derefed atom if empty, otherwise it pushes it

justinlee19:07:14

why would it be called derefed if it were a component?

justinlee19:07:20

you deref atoms, not components

rnagpal19:07:37

but from this I understand that

IDeref
  (-deref [this]
    (notify-deref-watcher! this)
    state)
this id the Ratom itself

rnagpal19:07:30

But dont see the code where reagent capture the componets

rnagpal19:07:11

Can you please point me to the line, where reagent know which component derefs an ratom

justinlee19:07:44

no i cannot 🙂

rnagpal19:07:54

aah, this is pain for me

rnagpal19:07:16

I tried 2-3 time to understand and make sense of the source code

justinlee19:07:16

I really wish I had a stepping debugger

rnagpal19:07:23

but always failed

justinlee19:07:31

i’ve been trying to understand this code for 6 months. it’s too convoluted

rnagpal19:07:52

I think this is the part where I miss the connection

justinlee19:07:29

the only way to understand what reagent is doing is to treat it as a black box, create some experiments, and add some print statements

☝️ 4
justinlee19:07:42

are you trying to solve a problem or are you just curious?

rnagpal19:07:51

just curious

justinlee19:07:44

juho teperi is the only guy who seems to really grok the innards of reagent

rnagpal19:07:32

Who is the maintainer of the project ? I would love to add docs, if someone can review and merge it everynight

justinlee19:07:01

juho does most of the work, but there are several contributors. the original author disappeared around 2016. i don’t know what happened to him. several of us contribute to docs and more help would be welcome. doc PRs are welcome and are usually merged within a couple of days

lilactown19:07:54

it’ll be nice to have async Rendering and suspense built in to react so we can all ditch reagent 😉

justinlee20:07:17

well you’ll need something to deal with the ratom state management part

lilactown20:07:21

add-watch works 😛

lilactown20:07:41

yeah. I actually decided to eschew reagent and just use plain react with add-watch last night

lilactown20:07:27

ran into lack of cursors right away. added a “should-update” that at least saves some renders, but reagent does do a lot to try and squeeze performance out of the paradigm

justinlee20:07:38

i’ve actually thought about what lighterweight wrapper would look like

justinlee20:07:06

part of me wonders if a light react wrapper + a redux implementation would get you a lot of what people like about re-frame without the mountainous heap of complexity

justinlee20:07:57

i’m not so sure auto-watching is really all that useful. it isn’t hard to declare your subscriptions up front

justinlee20:07:21

i also don’t think there is that much utility in the magic of form-1 and form-2 components

lilactown20:07:34

as someone who has onboarded (well, still kind of in the process) an entire team to reagent, I can say that the ratom (and especially form-2) components are confusing as hell

lilactown20:07:01

@lee.justin.m I agree, I think that using atoms as state containers is nice because it’s very Clojure-y, but I also think that being explicit about what you’re tracking is better

grav21:07:20

I cannot seem to find the reference docs on Reagent’s hiccup syntax. Best I’ve found is this random (but concise) reddit comment: https://www.reddit.com/r/Clojure/comments/75d054/hiccupreagent_syntax_help/do5o0qh Are there any other goodies that I’m missing out on?

rnagpal21:07:31

Thanks @lilactown for helping. Going through that part