This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-08
Channels
- # atlanta-clojurians (1)
- # beginners (116)
- # cider (70)
- # cljs-dev (11)
- # cljsrn (2)
- # clojure (218)
- # clojure-italy (7)
- # clojure-nl (14)
- # clojure-nlp (11)
- # clojure-spec (8)
- # clojure-uk (113)
- # clojurescript (86)
- # core-async (14)
- # cursive (24)
- # datomic (64)
- # duct (1)
- # emacs (3)
- # fulcro (20)
- # graphql (10)
- # jobs-rus (1)
- # london-clojurians (1)
- # luminus (1)
- # nyc (1)
- # off-topic (24)
- # onyx (1)
- # parinfer (1)
- # pedestal (14)
- # portkey (11)
- # re-frame (36)
- # reagent (9)
- # reitit (5)
- # ring (1)
- # shadow-cljs (197)
- # spacemacs (21)
- # specter (22)
- # sql (15)
- # tools-deps (5)
I am porting my AskHN Who’s Hiring browser https://kennytilton.github.io/whoishiring/ from JS/Matrix to CLJS/re-frame. Going quite well, actually. But I have been using strings like “™” and (worse) unicode stuff like “⭑". Those are not getting translated so I see those exact strings in the browser. Anyone know who’s escaping those so the client does not handle them?
@hiskennyness is this what you are after: https://github.com/reagent-project/reagent/blob/master/doc/FAQ/UsingAnEntity.md ?
Perfect. Thx.
Hey, I am running into a weird re-frame subscription conceptual problem. I really like keeping all the logic out of the views but I have been struggling with how to use the result of a subscription as an input to another subscription without tainting the views with this logic.
So in the above I have a subscription that will return the currently selected type in my imaginary "list" view
I want to know how to effectively thread the result of the :selected-type
subscription as input to the :properties
subscription. Preferably as a subscription itself (see :list-properties
subscription handler) but I feel like needed to use reg-sub-raw
is really clunky.
@kasuko Providing a subscription as input to another is a built in feature of re-frame, and the subscription will only run when the value of the input subscription changes
See https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs for different patterns you can use
And a more in depth doc: https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md
@curlyfry Thanks, but I am aware of that feature, but it doesn't deliver on my needed solution. The above allows passing subscriptions as inputs to another handler but it does not allow multiple levels of resolution for the input subscriptions
Essentially I am trying to use subscriptions as I would functions and now I want to compose them like I would with functional composition ... but can't
If we pretended subscriptions were functions then it's very easy to do (output-sub (input1-sub) (input2-sub))
which is what the above subscriptions are doing ... but I want to do is (output-sub (input-sub1 (input-sub2)))
(re-frame/reg-sub-raw
:broken-list-properties
(fn [_ _]
(reagent/reaction
(let [[selected-type @(re-frame/subscribe [:selected-type])
props @(re-frame/subscribe [:properties selected-type])]]
props))))
See https://github.com/Day8/re-frame/blob/master/docs/SubscriptionFlow.md#reg-sub-raw
So there isn’t a “nice syntax” way to support it built-in, but it certainly is doable.
I ended up just making my own macro to capture the pattern, since I’ve used it quite often in some apps.
ended up just doing something ilke
(re-frame.utils/regsub
:broken-list-properties
{:q [] ;; <-- used if there were query args to use as well
:let [selected-type [:selected-type]
props [:properties selected-type]]}
props)
just so I wouldn’t have to do all that boilerplate code as often and also to be sure I didn’t forget to add a reagent/reaction
Ah so I was on the right track. Ya I will also have to look into ways to clean it up a bit. Thanks!
[Warning: preference question ahead,] Am I the only one tempted to group stuff by application semantics instead of re-frame role? eg, instead of having all events in one place have them in the source after the primary (perhaps only) component that would dispatch it?
With my events.cljs growing, I am now leaning more towards semantic grouping (let's call it modules?) I try to make each modules independent or have explicit dependcies. Sometimes this requires having a dedicated module init event.
Since app db can become a big glob of globals, I namespaced all keys and control access with cofx. That is, one module can only access another's data if it is 'exported' using cofx.
You are definitely not the only one, I’ve decided I like it much better with semantically-related stuff all in one file.
since clojurescript lacks the ability to add require
s programatically, it tends to get extremely verbose if you don't
Reagent is over-warning about un-keyed vectors. Sometimes I know what I am doing. Is there some way to turn that off? It makes a yuge mess in my console. Now I have to fake a key. And are these questions better on Stack Overflow?
So I recently started using re-frame-10x and last week the tool stopped showing up in chrome (v67.0.3396.79). It still shows up in firefox any ideas?
Nevermind, I cleared the Local Storage and everything is back to normal. Thanks for the sound board :)
@hiskennyness this might help ... https://stackoverflow.com/questions/37164091/how-do-i-loop-through-a-subscribed-collection-in-re-frame-and-display-the-data-a/37186230#37186230
“(into [:ul]…)” Diabolical! I love it. Thx!
“(into [:ul]…)” Diabolical! I love it. Thx!