Hi Sven,

So this is where you're going to want to use cursors. A cursor will isolate
change notifications to the path or getter that the cursor refers to. So,
either in the global scope or in a let outside of some rx you'll want to
write something like (def current-page (cursor state :current-page)). Then
you'll deref current page in your rx. Let me know if this works.

Aaron

On Fri, Nov 21, 2014 at 5:12 AM, Sven Richter <[email protected]>
wrote:

> Ok, after trying out some more I got it working in two different ways:
>
> 1. Declare a separate atom for the navigation. By using two different
> atoms changes are only propagated to the views that each specific atom uses
> (so it seems).
>
> 2. The original code stores a reference to a function in the session atom
> like this:
>   (session/put! :current-page index)
> And then the main view calls the function like this:
>    [:div#content (rx ((session/get :current-page)))]])
>
> I did this so that I don't keep a whole html structure inside an atom.
> This does not work.
>
> What works is this:
>   (session/put! :current-page (index))
>    [:div#content (rx (session/get :current-page))]])
>
> But I am not sure if this is a good approach.
>
> Best Regards,
> Sven
>
>
>
>
> Am Freitag, 21. November 2014 10:53:05 UTC+1 schrieb Sven Richter:
> > I created a minimal example from a chestnut project:
> https://github.com/sveri/freactive-example
> >
> > The relevant stuff happens in core.cljs and session.cljs. When you run
> the application, add some text to the input and then click the button, the
> input is rerendered, which is unexpected from my side.
> >
> > I hope that shows the problem I have.
> >
> > Best Regards,
> > Sven
> >
> > Am Freitag, 21. November 2014 10:13:35 UTC+1 schrieb Sven Richter:
> > > Hi Aaron,
> > >
> > > I took this idea from yogthos blog and the whole session namespace
> contains an freactive atom plus some helpers:
> > >
> > > (ns de.sveri.dockerui.session
> > >   (:refer-clojure :exclude [get])
> > >   (:require [freactive.core :refer [atom]]))
> > >
> > > (def state (atom {}))
> > >
> > > (defn get [k & [default]]
> > >   (clojure.core/get @state k default))
> > >
> > > (defn put! [k v]
> > >   (swap! state assoc k v))
> > >
> > > (defn update-in! [ks f & args]
> > >   (clojure.core/swap!
> > >     state
> > >     #(apply (partial update-in % ks f) args)))
> > >
> > >
> > > So I am assuming that I can nest (rx ...) calls and only the part that
> changes will get updated. Is that right?
> > > This is basically what I am trying to achieve right now.
> > >
> > > Best Regards,
> > > Sven
> > >
> > >
> > > Am Freitag, 21. November 2014 00:23:25 UTC+1 schrieb Aaron Craelius:
> > > > It should re-render the portion of your DOM that was in an rx that
> got invalidated. What does the implementation of sess/get look like?
> > > >
> > > >
> > > > On Thu, Nov 20, 2014 at 5:21 PM, Sven Richter <[email protected]>
> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have been playing around and like it so far.
> > > >
> > > > I experience some behavior here where I wonder if it is intended or
> if I am doing something wrong.
> > > >
> > > > I have a main-page which I mount like this:
> > > > (dom/mount! root (main-page))
> > > >
> > > > and which looks like this:
> > > > (defn main-page []
> > > > [...
> > > > [:div#content
> > > >     [(rx ((sess/get :current-page)))]]...
> > > > it loads the current page into the content div, this works.
> > > >
> > > > Now I have one page which looks like this:
> > > > (defn sub-page []
> > > >   [:div
> > > > ; ... some forms
> > > >    [(rx (di-table))]])
> > > >
> > > > (defn di-table []
> > > >   [:table
> > > >    [:tbody
> > > >     (for [di (sess/get :dis)]
> > > >       [:tr [:td (:name di)]
> > > >        [:td (:host di)]
> > > >        [:td (str (:port di))]
> > > >        [:td [:button {:id (:id di) :on-click
> #(delete-docker-instance (:id di))} "Delete"]]])]])
> > > >
> > > > It works as it rerenders when I change the state, however, it
> rerenders the whole page and not only the table, which I wouldn't expect.
> Is it possible to only rerender the table? I am using 0.1.0
> > > >
> > > > Best Regards,
> > > > Sven
> > > >
> > > > Am Montag, 17. November 2014 03:20:40 UTC+1 schrieb Aaron:
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > freactive (pronounced "f reactive" for functional reactive) is a new
> high performance, pure Clojurescript, declarative DOM library:
> https://github.com/aaronc/freactive
> > > >
> > > > It has a syntax very similar to that of Reagent and was in fact
> inspired by Reagent, Om, and others.
> > > >
> > > > I came up with it when I was doing some DOM programming after having
> spending a fair amount of time working with JavaFX (see my soon to be
> announced library fx-clj: https://github.com/aaronc/fx-clj). I thought Om
> and Reagent were very nice to work with (and actually inspired some what I
> did with fx-clj), but I felt from my desktop GUI experience, that I could
> take things a few steps further.
> > > >
> > > > freactive's main advantages over existing solutions are probably
> built-in animations support and slightly higher performance.
> > > >
> > > > Here are it's goals from the README:
> > > > Provide a simple, intuitive API that should be almost obvious to
> those familiar with Clojure (inspiration from reagent)Allow for
> high-performance rendering good enough for animated graphics based on a
> purely declarative syntaxAllow for reactive binding of any attribute, style
> property or child node
> > > > Allow for coordinated management of state via cursors (inspiration
> from om)Provide deeply-integrated animation supportAllow for cursors based
> on paths as well as lenses
> > > > Provide a generic items view component for efficient viewing of
> large data sets
> > > > Minimize unnecessary triggering of update eventsCoordinate all
> updates via requestAnimationFrame wherever possibleBe easy to debug
> > > > Be written in pure Clojurescript
> > > > Provide support for older browsers via polyfills (not yet
> implemented)
> > > > Any feedback is welcome!!
> > > > I'm not sure I like the name "freactive" - but it was the best I
> could think of at the time. Suggestions for alternative names are welcome.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > Note that posts from new members are moderated - please be patient
> with your first post.
> > > >
> > > > ---
> > > >
> > > >
> > > >
> > > > You received this message because you are subscribed to a topic in
> the Google Groups "ClojureScript" group.
> > > >
> > > > To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojurescript/99myJ9vLeKQ/unsubscribe.
> > > >
> > > > To unsubscribe from this group and all its topics, 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 a topic in the
> Google Groups "ClojureScript" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojurescript/99myJ9vLeKQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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