This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-21
Channels
- # admin-announcements (80)
- # beginners (19)
- # boot (11)
- # cider (27)
- # clojure (55)
- # clojure-berlin (2)
- # clojure-italy (9)
- # clojure-korea (3)
- # clojure-russia (3)
- # clojure-sg (5)
- # clojurescript (70)
- # cursive (9)
- # datascript (5)
- # datomic (7)
- # editors (2)
- # emacs (4)
- # jobs (11)
- # ldnclj (7)
- # off-topic (17)
- # om (6)
- # reagent (63)
- # spacemacs (8)
- # testing (2)
I'm trying it now with dynamic bindings but that obviously blows up when a component gets re-rendered since the binding will have evaporated.
Sometimes people sneak data though the React parent context. I might be able to do it that way...
but every time there’s a component lingering there’s a chance that it won’t capture the global state
The first render goes fine, but when I swap the ratom it gets the globally scoped value for *state*
and dies on rerender
such that I can define my components, layout
, without any pre-coordinated global references
(binding [*state* (reagent/atom {:baz “baz”})]
(reagent/render [layout] node))
(defn layout []
(let [state (deref *state*)]
[:h1 state]))
but it’d probably be better to write a full react component that accesses the context like I like
it’s also just really a reader monad… but there’s no composition of your hiccup forms, so, eh
I've read almost all the code of reframe, but one thing is not quite clear to me, why the dispatch function use core.async?
@benzen: event handlers can call dispatch during their execution, what should be app-db passed to them? it is easier to reason about app-db when only one event handler can be "in-flight” and its effects get committed to app-db, then next event is handled
dispatch-sync is there for convenience I think, but it cannot be called from event handlers
by the fact that we run on js with an atom in hand doesn't give us enought to be sure that there is only one event dispated at the time?
think about call stack, when dispatch is in flight, you can be somewhere deep building your next app-db, and in the middle you call another dispatch
what should happen then? what app-db should be passed in that nested dispatch? what should be done with the result?
if you need to call dispach within dispatch and you want it to be synchronous, simply call function which is implementing that inner event handler -you have control what app-db will be passed in and you have control how you incorporate the result
potential observers of re-frame event queue won’t see that, they will just see one event dispatched (which did more complex work maybe reusing code from other events)