I have change initstate to this:
(defn world-view [data owner opts]
(reify
om/IInitState
(init-state [_]
{:world []})
om/IWillMount
(will-mount [_]
(go (while true
(log (count (:data world)))
(if (= (count (:data world)) 0)
(let [world (<! (get-world (:dimensions opts)))]
(om/transact! data #(assoc % :world world)))
(log "never gets here")
(<! (timeout (:poll-interval opts)))))))
What I do not understand is why when I log the count of (:datat world) is that
it is always 0.
Also, how would I set some state on the component?
On Tuesday, June 10, 2014 2:04:30 PM UTC+1, David Nolen wrote:
> Your init-state method is not correct, it should return a map - using
>
> transact! there is not recommended. The tutorials/documentation cover
>
> some of these point. You could do what you want by setting some local
>
> state of the component after the first time to some other value and
>
> checking for that in your go loop.
>
>
>
> HTH,
>
> David
>
>
>
> On Sat, Jun 7, 2014 at 11:54 AM, <[email protected]> wrote:
>
> > I have the following component:
>
> >
>
> > (defn world-view [data owner opts]
>
> > (reify
>
> > om/IInitState
>
> > (init-state [_]
>
> > (om/transact! data [:world] (fn [] [])))
>
> >
>
> > om/IWillMount
>
> > (will-mount [_]
>
> > (go (while true
>
> > (let [world (<! (get-world (:dimensions opts)))]
>
> > (om/transact! data #(assoc % :world world)))
>
> > (<! (timeout (:poll-interval opts))))))
>
> >
>
> > om/IRender
>
> > (render [_]
>
> > (apply dom/table nil
>
> > (om/build-all row (:world data))))))
>
> >
>
> >
>
> > This works as expected what I want to do is to call a different method
> > after the initial get-world method has been called.
>
> >
>
> > After get-world has been called I then want to call a different method that
> > does a PUT with the data returned from get-world. The setTimeOut function
> > would then call this PUT on every time out.
>
> >
>
> > I'm not sure how to update the data after the initial get-world has been
> > called.
>
> >
>
> > --
>
> > 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.