re-frame is an entirely different framework
(https://github.com/Day8/re-frame/wiki/Solve-the-CPU-hog-problem). I
am not stating this can't be solved in om, only that you need to build
your own solution where as in re-frame it is taken care off. FWIW, I
solved this in om by writing the calculated data to app-state.

In om, a component won't be rendered if the 'related data' hasn't
changed, so it is fine to do something like:

(defn thin-row [{:keys [a b]} owner]
  (reify ...
    (render ... (html [:tr [:td (some-very-expensive-calculation-for
a)] [:td b]])))

(defn table [sequence-of-fat-maps owner]
  (reify...
    (render ... (html [:table [:tbody (om/build-all thin-row (map
(partial select-keys [:a :b]) sequence-of-fat-maps))]))

(as untested as it can possibly be and assuming saloon html)

My understanding is that om will render the 'table' but it will only
call 'thin-row' for each of the rows where 'a' or 'b' have actually
changed. For those where the input to 'thin-row' is the same, om will
instruct react that they haven't changed and thus
(some-very-expensive-calculation-for) is skipped. In this scenario you
would also want to add a unique key to each row as well.




On 25 March 2015 at 12:22, Andrew S <[email protected]> wrote:
> Thanks Colin. Couple of followups:
>
> 1) What is re-frame? I couldn't find that on the Om documentation page.
>
> 2) If I have a parent observe an entire reference cursor (or any cursor for 
> that matter), then wouldn't the parent re-render when any individual 
> key/value in the reference cursor updates? And thus if the parent re-renders, 
> then doesn't this mean the parent re-renders all of its children? Perhaps I 
> don't entirely understand the render tree process in Om, but I thought if a 
> component re-renders, then it would also re-render any other components it 
> creates/builds. If only one of my children actually needs an updated value, 
> then the entire parent re-rendering is a waste and the sort of thing I'm 
> trying to get around.
>
> --
> Note that posts from new members are moderated - please be patient with your 
> first post.
> ---
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to