This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-23
Channels
- # 100-days-of-code (5)
- # announcements (3)
- # beginners (68)
- # cider (2)
- # cljdoc (2)
- # cljs-dev (10)
- # cljsjs (2)
- # clojure (40)
- # clojure-austin (2)
- # clojure-dev (17)
- # clojure-italy (8)
- # clojure-spec (4)
- # clojure-uk (9)
- # clojurebridge (1)
- # clojurescript (48)
- # datomic (4)
- # emacs (4)
- # figwheel-main (93)
- # fulcro (8)
- # hyperfiddle (33)
- # jobs-discuss (3)
- # luminus (60)
- # off-topic (66)
- # onyx (42)
- # pedestal (11)
- # re-frame (35)
- # reagent (1)
- # reitit (39)
- # shadow-cljs (30)
- # specter (27)
@sveri the todomvc example has some guidance https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs#L59-L68
and https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs#L59-L68
@mikethompson Thanks, thats a usefule link 🙂
So I'm using the app structure for larger apps as described here: https://github.com/Day8/re-frame/blob/master/docs/Basic-App-Structure.md#larger-apps
I basically have something like the events in events.cljs get dispatched successfully but the ones in pane1/events.cljs get ignored - pane1/events.cljs - events.cljs
@urbanslug is the namespace panel1.events
being required in your core namespace? (Or by a namespace that is required by your core namespace)
@gadfly361 it's not, should it?
It's an easy thing to miss. They would register normally .. but the compiler (being unaware of the side effect) thinks that namespace isn't used so ignores it. By including it in the core namespace, you're telling the compiler specifically .. no I want to keep this!
Thank @gadfly361 I appreciate the help. I just didn't have it required in the core.cljs
I'm trying to build a diagramming tool with re-frame. There's an svg element containing all the diagram elements. I'm tracking clicks via an on-click handler on the svg element. But the effect of the click event depends on the currently selected tool. Is the correct way to do this to have the onclick handler @
a subscription to the event? the other way is to have a parent click event handler dispatch a new event depending on exactly what it needs to do: but then the event handler has to either read the database or subscribe to the currently selected tool, and that seems like more behavior than there should be in event handling
(also that seems to promote that that the event handler knows how the current tool is stored, though I guess event handlers are already pretty tied to subscriptions that way)
@lvh event handlers do the processing. They interpret the click. The currently selected tool would be in app-db
and they have access to that data. The thought of subscribing to events seems very off-kilter
subscriptions are just a way of obtaining the new state (created by the event handler when interpreting the event)
So your event handlers typically process browser event objects? Doesn’t that make them harder to test?
event handlers are just functions.
They get two inputs (current state and event) and they compute an output (new state)
So they are super easy to test
Sorry, I'm going to have to fly. Be sure to read through the docs to get the right feel for how to architect.
There are example apps, etc
Further resources