This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-30
Channels
- # arachne (1)
- # beginners (1)
- # boot (13)
- # cljs-dev (35)
- # cljsjs (12)
- # cljsrn (11)
- # clojure (77)
- # clojure-austin (14)
- # clojure-brasil (3)
- # clojure-france (1)
- # clojure-poland (4)
- # clojure-russia (23)
- # clojure-spec (39)
- # clojure-uk (14)
- # clojurescript (17)
- # cursive (16)
- # datascript (10)
- # devcards (1)
- # dirac (3)
- # editors (1)
- # emacs (4)
- # jobs (1)
- # jobs-rus (2)
- # luminus (5)
- # off-topic (1)
- # om (85)
- # parinfer (1)
- # perun (12)
- # re-frame (20)
- # reagent (4)
- # spacemacs (1)
- # specter (9)
- # yada (6)
@danielpquinn: subscriptions used within a view component (reagent) will be correctly unsubscribed when that (reagent) component no longer exists. But if you just call subscribe outside of a view component, then yes the subscription will not be gotten rid of.
@mikethompson In that case, what is the best way to access values in my app-db outside of my view code? Is that an anti-pattern?
event handlers are given db
as a argument
And they return the mutated version of it.
okay cool, I suppose I could put this piece of code in an event handler, but it might not mutate the db depending on whether values are valid.
thanks for your help!
Maybe I should put the validation code in middleware?
I’ll keep digging around 🙂
We sometimes use enrich
(middleware) for that purpose
I’ll have to google that one, thanks for the tip
The idea is that you attach enrich
middleware on every event handler which might cause a change to the state which needs to be validated. If the enrich middleware finds an error it assocs error details into db
(or disassoc if no validation errors found). The view code responds the existance of "error details" in db and renders the necessary view.
that sounds like a sensible approach. I’m still getting used to keeping everything in a global state structure
wouldn’t have thought to put error details into that state object
This does keep everything in app-db.
I'm slight confused, your last two comments seem to contradict
Sorry, it was probably my wording. I think we’re on the same page 🙂
Just to be clear enrich
allows you to post process db
... after an event handler has run.
Perfect spot for validation
cool, ty