This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-19
Channels
- # adventofcode (82)
- # beginners (70)
- # boot (34)
- # boot-dev (13)
- # cider (45)
- # clara (4)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (91)
- # clojure-art (8)
- # clojure-czech (1)
- # clojure-dusseldorf (3)
- # clojure-france (11)
- # clojure-germany (1)
- # clojure-greece (39)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-norway (2)
- # clojure-spec (7)
- # clojure-uk (31)
- # clojurescript (56)
- # core-async (7)
- # cursive (8)
- # data-science (10)
- # datomic (41)
- # duct (7)
- # emacs (1)
- # events (1)
- # fulcro (83)
- # graphql (6)
- # klipse (1)
- # leiningen (28)
- # lumo (67)
- # off-topic (14)
- # om (9)
- # onyx (3)
- # perun (4)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (2)
- # rum (1)
- # specter (46)
- # sql (13)
- # uncomplicate (17)
- # unrepl (114)
@jarrodctaylor I'd suggest you read Eric's article ... https://purelyfunctional.tv/guide/database-structure-in-re-frame/ Look in particular at the "Naming Recommendations" section. We want our views to dispatch events which capture user "intent".
We don't want logic in views
Your first attempt put logic into the view, and tried to use dispatch
as a kind of "function call"
mikerod correctly pointed you towards an alternative version where the view simply dispatches an event which captures the user's intent and then it is up the event handler to know how that intent should be implemented (never the view)
@mikethompson yeah I wasn’t sure on the name either. The situation was generic so i didn’t know of a semantic “intent”. I was almost going to mention the naming thing too
any nice way to use namespaced keywords but still have handlers that can be shared across different namespaces?
we are using namespaced keywords now, which is nice, but sometimes it's quite a pain to try to share handlers across different pages
I just recently learned the trick where you (require '[some.big.long.hard-to-type.namespace :as sblhn])
and then you can use ::sblhn/my-keyword
instead of typing out the whole thing.
Does that help?
@manutter51 I was goign to say the same thing 😛
Yeah, I have some like that too, I just consider those to be "keywords with built-in documentation". More to type, but worth the effort.
yeah I knew that trick
but it doesn't really help in a way since each page has a different db for example
and if I want to use the same handler function in two pages, I can't use do it directly with namespaced keywords
could maybe pass the caller namespace into the function maybe, but it's not really great
Maybe you need to refactor your namespaces, and/or use namespaced keywords that don’t correspond to an actual ns?
Like if you have something in a foo
namespace and you want to share it with a bar
namespace, pull it out of foo
into like common
or util
or something.