-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: are cursors more update-efficient than a massive atomic hash-map? #47
Comments
Yes, cursors should be more efficient if used correctly. Especially the new cursor implementation. You can write Although, it's not documented yet (haven't had the time) there is a fn in freactive.core |
Also, |
Wow, thanks so much for the impressively quick reply! I really appreciate the helpful hints - I'll make good use of them. Also, I really have so much respect for what you've accomplished in this library - about how easy-to-use and well-reasoned it all is, and about how you respond so quickly to new issues, etc. If you don't mind me asking, is this a side project, part of a master's project, part of a work assignment - how did this come about? |
Mostly to support commercial projects. I hacked together freactive.dom On Fri, Jun 12, 2015 at 6:52 PM, alexandergunnarson <
|
Yeah, I had frustrations with reagent, even though it really is the simplest of all reactive ClojureScript UI libraries that I know of (besides freactive), and I never even tried om because I took one look at it and it just shouted "incidental complexity". I'm also trying to put a commercial app into production with this, but it may take a while because I'm the sole developer at the moment. |
Good luck! Curious - are there particular frustrations you had with reagent On Fri, Jun 12, 2015 at 7:07 PM, alexandergunnarson <
|
Can you explain why |
It's not only redundant, it adds overhead. Any IWatchable is bindable
|
In my experiments I'm having trouble with cursors that aren't "leaf nodes" or that point to something like a js/Date. object. The code in question is here: https://github.com/pkobrien/ing/blob/93aeda2b2fb6c89a5ba214ad4b7e38c5d2af485b/styling/src/app/core.cljs Here is a simplified portion:
Based on this example it looks like rc-mouse-pos-x and rc-mouse-pos-y (leaf nodes) can be bound directly, but rc-mouse-pos (interior node) cannot. |
Yeah so, in order to bind a ref it has to be a direct child of an element. |
I often tend to put my application state in an all-encompassing one-or-two-level-deep hash-map wrapped in an atom. Let's say that a DOM element
:div#a
reactively (i.e., via therx
macro) changes its color based on(-> @state :div#b :style :color)
. Now let's also say that:div#c
reactively changes its color based on(-> @state :div#d :style :color)
. Div A depends on div B, and C on D, but [A and B] do not affect [C and D] at all, and vice versa.Now suppose that
(swap! state assoc-in [:div#b :style :color] :white)
is called. Because the value ofstate
is atomically modified, are the colors of divs A and C considered "dirty" and thus the values must be recalculated by calling the functions whichrx
created for each of them respectively? Or does freactive know that only div B's color was changed and so C's does not need to be recomputed?This brings me to the question in the title: would cursors be more efficient in this case? Instead of writing code like so:
...should I write code like this?:
That is, would cursor
c
only be invalidated if div B's color changed and not on every modification tostate
?Thanks for your time!
The text was updated successfully, but these errors were encountered: