This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-13
Channels
- # aleph (3)
- # aws (1)
- # beginners (97)
- # boot (41)
- # cider (7)
- # clara (105)
- # cljs-dev (4)
- # cljsrn (66)
- # clojure (185)
- # clojure-argentina (2)
- # clojure-colombia (15)
- # clojure-czech (1)
- # clojure-dusseldorf (8)
- # clojure-greece (2)
- # clojure-italy (5)
- # clojure-russia (33)
- # clojure-spec (14)
- # clojure-uk (9)
- # clojurescript (75)
- # cursive (6)
- # data-science (1)
- # datomic (12)
- # emacs (2)
- # fulcro (71)
- # funcool (1)
- # jobs (6)
- # jobs-discuss (62)
- # juxt (21)
- # lein-figwheel (1)
- # luminus (9)
- # lumo (41)
- # off-topic (39)
- # om (12)
- # onyx (1)
- # portkey (2)
- # protorepl (4)
- # re-frame (14)
- # reagent (50)
- # ring (3)
- # shadow-cljs (6)
- # spacemacs (38)
- # specter (8)
- # test-check (14)
- # testing (52)
- # unrepl (2)
how do i go about using values passed to a dynamic subscription? in this example i need the 'specific-id' value in my second function:
(reg-sub
::one-list
(fn [[_ specific-id]]
[(subscribe [:lists/filtered-lists])])
(fn [[filterd-lists]]
; Need access to specific-id for something like:
; (filter #(= specific-id (:id %)) filterd-lists)
))
this doesn't work because the second function expects only input signals:
(reg-sub
::one-list
(fn [[_ specific-id]]
[specific-id (subscribe [:lists/filtered-lists])])
(fn [[specific-id filterd-lists]]
; Need access to specific-id for something like:
; (filter #(= specific-id (:id %)) filterd-lists)
))
@joshkh bit of a hack, but could you wrap specific-id
in a reaction
? Not tried that so not sure if it would work, or if it’s advised!
@joshkh For the computation function in a subscription it takes 2 arguments. The first is the input signals and the second is the subscription vector. Thus you should be able to do
(reg-sub
::one-list
(fn [[_ specific-id]]
(subscribe [:lists/filtered-lists]))
(fn [filtered-lists [_ specific-id]]
; Need access to specific-id for something like:
(filter #(= specific-id (:id %)) filtered-lists)
))
Infact since you aren’t even using the specific-id
in the inputs function you can use the syntatic sugar
(reg-sub
::one-list
:<- [:lists/filtered-lists]
(fn [filtered-lists [_ specific-id]]
; Need access to specific-id for something like:
(filter #(= specific-id (:id %)) filtered-lists)
))
that's weird, i could have sworn i wasn't getting the argument vector in your first suggestion:
(reg-sub
::one-list
(fn [[_ specific-id]]
(subscribe [:lists/filtered-lists]))
(fn [filtered-lists [_ specific-id]]
; Need access to specific-id for something like:
(filter #(= specific-id (:id %)) filtered-lists)
))
i'll go back and take another look. thanks, @kasuko