Fork me on GitHub
#re-frame
<
2018-03-18
>
danielcompton02:03:50

Yeah, you might want to be careful about how you measure it, certain properties that you touch on the DOM cause a full reflow, not sure whether screen width is one of them or not

raymcdermott14:03:40

I’m trying to integrate a WS callback using sente and there don’t seem to be any good examples of the prior art

raymcdermott14:03:26

so I guess I might have to write a sente-ws-fx component …. please try to stop me 🙂

atticmaverick17:03:16

is it better to use a subscription within a subscription or just access the same keys as the other subscription?

atticmaverick17:03:50

a subscription within a subscription sounds nice because changes to the map would only need to be updated in one subscription. but im not sure if this would cause any issues

mikethompson22:03:55

@raymcdermott I googled for "sente re-frame" and got a few hits

raymcdermott16:03:50

I went for this in the end

raymcdermott17:03:25

(reg-event-db ::eval-result (fn [db [_ eval-result]] (let [eval-results (or (:eval-results db) [])] (assoc db :eval-results (conj eval-results eval-result))))) (reg-fx ::send-eval (fn [{:keys [form-to-eval timeout]}] (when-not (str/blank? form-to-eval) (chsk-send! [:example/repl {:form form-to-eval}] (or timeout 3000) (fn [eval-result] (re-frame/dispatch [::eval-result eval-result])))))) (reg-event-fx ::eval (fn [cofx [_ form-to-eval]] {:db (assoc (:db cofx) :form-to-eval form-to-eval :eval-result nil) ::send-eval {:form-to-eval form-to-eval}}))

raymcdermott17:03:51

damn slack threads don’t offer nice formatting it seems

raymcdermott17:03:59

anyway, you get what I mean

raymcdermott17:03:16

and I will put it out on the github relatively soon

raymcdermott17:03:00

most of the ones that I saw always start on the server so are not as ‘pure’ client side as I want

mikethompson22:03:47

Are you saying there are no effects handlers among them?

mikethompson22:03:59

Hmm. I see what you are saying. No effects handlers. odd. And a tighter Gihub search doesn't do better: https://github.com/search?utf8=%E2%9C%93&amp;q=sente+re-frame+&amp;type=

mikethompson22:03:44

@atticmaverick generally you'd use layered subscriptions because the "layer 3" does some CPU intensive computation and you want a layer 2 to just do an extraction from app-db and prune the propagation to layer 3 when there's been no change to the inputs.

mikethompson22:03:23

Accessing map keys is not a very CPU intensive process generally. So, normally, I wouldn't bother.

atticmaverick23:03:56

@mikethompson Thanks. That's kind of what i gathered from testing it. It seemed to work fine. I will look into the layered subscription so I can have a better understanding.

atticmaverick23:03:25

Perfect! That documentation is amazing. So easy to understand. Thanks again!