Oops, I should have read that more carefully! What Dave says is correct:
local state does not contain cursors.

I also agree with his statement app vs local state: keep your domain
information in app-state (think of it as the state you would persist to a
database or save to disk), keep transient state about how something is
being displayed (eg current tab in a tab widget) in local state, and
configuration options that don't change in opts.


On 4 May 2014 16:22, Dave Della Costa <[email protected]> wrote:

> The reason this is not working is because you are explicitly ignoring
> the first (what would be the cursor) argument to your component, so
> neither transact!/update! (which works on your cursor, not local
> component state) or set-state!/update-state! (which is applied to local
> component state--what you retrieve with get-state) will work.
>
> On a more conceptual level I would recommend keeping application
> data--which stuff like "domain" and "customer-info" most certainly
> are--in your cursor (a.k.a. "app data" a.k.a. the first arg to
> component) vs. in your state.  This will solve a number of your problems.
>
> DD
>
> (2014/05/04 23:33), Roger Gilliar wrote:
> > My component looks like this:
> >
> > (defn- domain-data [_ owner]
> >   (reify
> >
> >     om/IInitState
> >     (init-state [_]
> >       {:domain nil})
> >
> >     om/IWillMount
> >     (will-mount [state]
> >       (th/poll @chan (fn[data] (om/set-state! owner :domain data)))) ;;
> sets the state with a selected domain
> >
> >     om/IRenderState
> >     (render-state [this state]
> >      (if-let [domain (:domain state)]
> >         (dom/div nil
> >                  (om/build header/header-comp domain)
> >                  (om/build (customer-info/create update-chan) (get-in
> state [:domain :customer-info])))
> >         (dom/span nil "")))))
> >
> > It seems that (get-in state [:domain :customer-info]) doesn't create a
> cursor. Because some lines down the source I get
> >
> > No protocol method ITransact.-transact! defined for type
> cljs.core/PersistentArrayMap
> >
> > as soon as I try to call
> >
> > (om/transact! app-state assoc key value);  app-state is the result of
> the get-in call
> >
> > BTW:
> >
> > The customer-info/app-state may look like this:
> > {:customer-nr "12332233", :customer "a company", :ip "122.122.1.23",
> :description "database server"}
> >
> >
> >
> >
>
> --
> 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