This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-21
Channels
- # announcements (24)
- # aws (2)
- # babashka (20)
- # beginners (147)
- # cider (20)
- # clara (43)
- # clj-kondo (3)
- # cljdoc (15)
- # cljsjs (1)
- # cljsrn (36)
- # clojars (19)
- # clojure (64)
- # clojure-europe (4)
- # clojure-italy (45)
- # clojure-nl (1)
- # clojure-spec (20)
- # clojure-uk (26)
- # clojurescript (16)
- # cursive (9)
- # datomic (18)
- # dirac (14)
- # docker (3)
- # fulcro (48)
- # keechma (1)
- # leiningen (32)
- # luminus (1)
- # off-topic (40)
- # pedestal (1)
- # quil (1)
- # re-frame (24)
- # reagent (3)
- # reitit (3)
- # remote-jobs (2)
- # ring-swagger (4)
- # shadow-cljs (115)
- # spacemacs (22)
- # specter (4)
- # tools-deps (76)
anyone tried to get around the 'dont reference a subscription inside event-handler' problem by messing with *ratom-context*
? (i know the other ways, but this may be better)
I wouldn't do that. *ratom-context*
is an implementation detail as it doesn't appear to be in the public API.
what if every re-frame event handler was wrapped like this? https://github.com/reagent-project/reagent/blob/9a7372d8ecf881a974877441e094fd71a665367b/src/reagent/ratom.cljs#L268-L270
I just mean there are worse things than relying on implementation details of some project - it can be a problem, but not necessarily a fatal flaw
But why would you want to do that, given that there is a solution already that doesn't do that?
For me, "[the existing perfectly working solutions] seem awkward" and "there are worse things" are not good enough justifications to rely on something that I ought not to rely on.
A good technical reason is that *ratom-context*
is an implementation detail.
BTW your solution would probably break dispatch-sync
. But I'm not sure about that.
conceptually, you should not be referencing subscriptions inside event-handlers anyway; a handler gets passed a snapshot of state of the world and should not depend on anything else – in particular not on a subscription which is a reactive stream of changes to some of that state.
right now I was mostly thinking of the leak issue, but good point, would also need to solve that
@isak There are existing methods which require no hackery. This link should help: https://github.com/day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md
@mikethompson that seems unrelated. I think you mean this, right? https://github.com/day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md
Very different documents for very different purposes
You want to get at a subscribed value in :component-will-mount
, yes?