This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-17
Channels
- # aws (10)
- # beginners (64)
- # boot (3)
- # cider (20)
- # cljs-dev (32)
- # cljsrn (6)
- # clojure (126)
- # clojure-dusseldorf (3)
- # clojure-finland (1)
- # clojure-greece (1)
- # clojure-italy (7)
- # clojure-poland (3)
- # clojure-spec (46)
- # clojure-uk (100)
- # clojurescript (37)
- # cursive (11)
- # datomic (6)
- # defnpodcast (2)
- # emacs (1)
- # events (3)
- # figwheel (2)
- # fulcro (20)
- # immutant (2)
- # jobs (1)
- # jobs-discuss (9)
- # keechma (3)
- # lein-figwheel (1)
- # luminus (2)
- # lumo (3)
- # mount (2)
- # off-topic (19)
- # om (3)
- # om-next (2)
- # onyx (20)
- # other-languages (55)
- # parinfer (11)
- # pedestal (8)
- # portkey (3)
- # protorepl (3)
- # re-frame (22)
- # ring (9)
- # rum (1)
- # shadow-cljs (82)
- # spacemacs (28)
- # sql (15)
- # test-check (15)
- # testing (2)
- # tools-deps (102)
- # vim (26)
what are you trying to achieve here?
I would add a logging statement to the on-dispose for the reaction to check if it is cleaned up
But at first glance I think it would be fine
Though I don't really understand the wider context here
@danielcompton I'd like to have a reg-sub-computation
that takes an output-signal-fn
and computation-fn
. output-signal-fn
is passed the re-frame DB or a vector (or single obj) of signals and the event-vec and is expected to return a Reaction R
. I want to run computation-fn
on the value of R
only when its value changes. Essentially the below code (the excerpt is take from our existing codebase so it's not in its actual form)
(defn reg-sub-computation
[query-id signals output-signal-fn computation-fn]
(reg-sub-raw
query-id
(fn [*rf-db event-vec]
(ratom/make-reaction
(fn []
(computation-fn @(ratom/make-reaction
(fn []
(let [input-signals (normalize-signals signals event-vec)]
@(output-signal-fn (if signals
(if (sequential? input-signals)
(mapv deref input-signals)
@input-signals)
(deref *rf-db))
event-vec))))
event-vec))))))
I also have a function called reg-sub-raw-wrap
which I tend to use more than that one because it tends to be a bit more clear, albeit more verbose. That function simply does this:
(defn reg-sub-raw-wrap
"Like [[reg-sub-raw]] except wraps `handler-fn` in a reaction."
([query-id opts handler-fn]
(reg-sub-raw
query-id opts
(fn [*rf-db event]
(ratom/make-reaction (fn [] (handler-fn *rf-db event)))))))
@kenny that is making my head hurt a bit.
Frankly, I'm not sure I'm following
Is it possible to give a more "wordy" explanation. I feel like you might be on the wrong path but I'm struggling to figure out where you want to get to .
There is a bit of functionality that isn’t possible with the default reg-sub that that function was trying to solve. I also agree — it is a little mind bending — and I actually use the reg-sub-raw-wrap in favor of it because it reads a lot cleaner. There may be an abstraction hiding underneath and I don’t think that function is it. It would probably help to have a concrete example problem.
Sounds like you want a change event to propagate if and only if there’s a value that’s different? To avoid unnecessary, potentially expensive calculations?
Hi, Looking through examples I have a question about views. All I see are three different kinds:
; returning a fn
(defn view []
(fn []
(let [:baz (rf/subs [:ev])]
[:div ...])))
;the let form first
(defn view []
(let [:baz (rf/subs [:ev])]
(fn []
[:div ...])))
; just returning a vec
(defn view []
[:div ...])
Which is the correct one to use?In most simple cases you can use the third one now
because subscriptions are cached, you can call (subscribe [:subscription ...])
wihtout fear
I think there's a discussino about it somewhere
@danieleneal Thanks, that was a very helpful link, exactly what I was looking for and its great they introduced these changes. @plexus Very well written article, thank you for that.
i was thinking this:
(->interceptor
:id :enrich-fx
:after (fn enrich-after-fx [context]
(assoc context :effects (merge (:effects context)
(f (:coeffects context))))))
but i want to make sure im not clobbering the ins/outs@lwhorton nothing like that in the API