This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-23
Channels
- # beginners (55)
- # boot (37)
- # braid-chat (1)
- # chestnut (3)
- # cider (4)
- # clara (22)
- # cljs-dev (54)
- # cljsrn (3)
- # clojure (114)
- # clojure-italy (12)
- # clojure-losangeles (3)
- # clojure-portugal (1)
- # clojure-russia (1)
- # clojure-spec (30)
- # clojure-uk (67)
- # clojure-ukraine (1)
- # clojurescript (101)
- # core-async (11)
- # cursive (6)
- # data-science (27)
- # datomic (8)
- # figwheel (3)
- # fulcro (59)
- # graphql (2)
- # hoplon (89)
- # jobs (3)
- # jobs-rus (1)
- # leiningen (3)
- # lumo (19)
- # off-topic (9)
- # om (48)
- # pedestal (2)
- # portkey (4)
- # protorepl (19)
- # re-frame (13)
- # reagent (38)
- # remote-jobs (1)
- # ring-swagger (4)
- # spacemacs (10)
- # specter (2)
Hello,any one knows why my program can't receive re-frame subscription?
the event has fired and dispatched
the event handler had been called
but I can't receive the subscribtion
Very hard to say without a minimal gist demonstrating the code you have written. But in the absence of good information, I'd wildly speculate along the following lines ...
1. did you put debug in the subscription's computation function? Is it running? My guess is no.
2. Did you deref the subscription in the view. Put a @
in front?
Other than that you'll have to be a lot clearer with your question. A minimal gist is best
Thanks for your reply. for 1, I did put debug code in subscription code and it is not running
for number 2, I had @ in front of the subscription
I'm trying to put the code in a gist
I use a re-frame-datatable component
I suspect that may be cause of the problem?
gist is following: https://gist.github.com/hughjfchen/7f8f7328be1b055d8df18e6d1f021b4a
really can't figure out why can't receive the :edit-checklist subscription
Dunno if this is the issue, but don't use with-let
just use let
??
I've tried just using let, can't receive the subscription either
I got an warning when trying create hiccup from npm-deps: Warning: Using native React classes directly in Hiccup forms is not supported. Use create-element or adapt-react-class instead: JsonTree
Can someone tell me how to use this library in reframe? https://github.com/TeamWertarbyte/material-auto-rotating-carousel
@sam16 You can probably just use adapt-react-class
https://gist.github.com/frankiesardo/17905c5ec26bfc84df7d
@hugh.jf.chen in your gist, you're not registering the :edit-checklist
subscription anywhere
your
;; sub reg function
(defn query [db [event-id]]
doesn't actually register a subscription. And it's not called anywhere else in the gist.Add this:
(re-frame.core/reg-sub
:edit-checklist
(fn [db _] (:edit-checklist db)))
Or maybe, you'd actually want the following:
(re-frame.core/reg-sub
:open?
(fn [db _] (if (:edit-checklist db)
true
false)))
And like @mikethompson said, just use a let
. I don't know what the with-let
does, but your code doesn't seem to suggest you need anything other than a let
.
(actually, re-frame doesn't demand you to use the let
for technical reasons either, but of course, you might want it because you feel it makes your code easier to read : )
I was curious, for reference this is what with-let
is https://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L17 *(fixed with better link for def)
Does anyone have experience writing Higher Order Components in Reagent? Any pointers to good examples?
I'm looking for a way to build reusable pieces of functionality that can be added to existing components in a composable manner.
@noisesmith I looked it up myself as well, not the definition, though, just a reference to it in a reagent update - looks to me like a boilerplate-removing way of doing:
(defn my-component [a b c]
(let [s (subscribe [:some-path])]
(fn render-my-component [a b c]
... ;; component implementation goes here, somewhere dereffing s
it allows a finalize too
alright 🙂
@reefersleep Thanks for your reply. Actually, I have following snippet in the same namespace of the query function: (reg-sub :edit-checklist query). So I think I'd register the subscription for :edit-checklist.
OK. I think I figured it out. Because no one calls the checklist-edit-form function. Once I add a call to the checklist-edit-form function somewhere in my code. I can receive the subscription. Maybe re-frame think there's no deed to deliver the subscription if there's no subscribe call. Sounds reasonable.
@hugh.jf.chen nodes in the signal graph are ONLY instantiated when they are needed
And they are only needed when a view exists and does a subscribe.
See the last slide in this infographic https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md