This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-15
Channels
- # 100-days-of-code (3)
- # announcements (14)
- # beginners (100)
- # calva (20)
- # cider (50)
- # cljdoc (29)
- # cljs-dev (6)
- # clojure (78)
- # clojure-europe (1)
- # clojure-italy (8)
- # clojure-losangeles (1)
- # clojure-nl (11)
- # clojure-uk (108)
- # clojurescript (23)
- # code-reviews (5)
- # cursive (7)
- # datomic (11)
- # devops (1)
- # editors (1)
- # figwheel-main (65)
- # fulcro (114)
- # hoplon (31)
- # hyperfiddle (1)
- # juxt (4)
- # lein-figwheel (2)
- # nrepl (13)
- # off-topic (72)
- # re-frame (35)
- # reagent (9)
- # shadow-cljs (42)
- # spacemacs (2)
- # specter (5)
- # tools-deps (60)
- # yada (2)
I have what is probably a very stupid question - how does a subscription know its value has changed?
using random example from re-frame docs I have open, say I write:
(re-frame/reg-event-db
:set-active-panel
(fn [db [_ value]]
(assoc db :active-panel value)))
(re-frame/reg-sub
:active-panel
(fn [db _]
(:active-panel db)))
when I then do a (re-frame/dispatch [:set-active-panel :panel1])
, how does re-frame know that whatever is subscribing to :active-panel
needs to be refreshed?
right now I'm dealing with a situation like this: I have subscriptions A and B, and then a subscription C that uses A and B as input vectors, and just concatenates them) my component subscribes to C, and there are input fields that trigger calls which change (via an event-db dispatch) values that are listened to by A and B
somehow, C does not catch the fact that values in DB are changed, and in trying to figure that out I realize I can't find any info on how do subscriptions actually know what's going on
moreover, looking at the app state via re-frisk, I discovered that even A and B don't notice changes in the DB
re-frame-10x
is a tool which provides more information on when subscriptions are run and what values they create.
You generally don't need to know how it works
BTW, if the new value A
tests =
to the old value of A
then no change is propogated
I just fixed the problem, turns out it was PEBKAC (like usual), a mistake with qualified/unqualified keys
still, knowing how this works under the hood would help me keep some peace of mind 🙂
for instance, I have some subscriptions I inherited in the codebase that look like (or (get-in app-db [:foo :bar]) (some-default-computed-value))
, and yet they update themselves if the db state under :foo :bar
changes
I'd encourage you to read the docs: https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md
Also read the link at the bottom of that page, to the todomvc example. It is heavily commented.
I think the answer to my question is actually on "The Signal Graph - a four layer tree" part of the flowchart, where there's a note that data flow stops when a subscription returns unchanged value
related to this question (https://clojurians.slack.com/archives/C073DKH9P/p1539431269000200) which I maybe asked at the wrong time/day
I got something vaguely working but I'm not sure it makes so much sense, and strangely I can't really find anything online about that
anyone doing that who would like to share how they do oauth2 authentication in general? (Maybe it's more a SPA question more than a re-frame problem specifically)
@andrea.crotti did you read this doc? https://github.com/Day8/re-frame/blob/master/docs/SubscriptionFlow.md
Sure that's not the problem really
Just wondering what are the possible ways to do oath2 authentication in reframe
The flow all works now, I have an endpoint that tells the frontend if the user is authenticated, and put that in the db
oath2? Oh, sorry, your link seemed to take me to a discussion on a subscription topic.
@temporal.pl you might also be interested ^^^ vvv
Be sure to read through all the docs. https://github.com/Day8/re-frame/tree/master/docs