Your code looks fine, the `init-state` bit is unnecessary. The issue is that you're trying to directly print `tasks` for debugging in `add-new-tasks`, this isn't allowed. If you want to print the value of tasks for debugging in an async event handler you must deref.
(.log js/console "callback/handle-new-task" @tasks) David On Wed, Apr 9, 2014 at 6:03 AM, Florian Salihovic < [email protected]> wrote: > I am worked though the basic tutorial of Om and used it as a starting > point for a small sparetime project. > Of course it didn't went as smoothly as I hoped it would. > > The error appeared when I was trying to add new data to the application > state before I implemented om/IInitState and created a property for tasks > in the state object. > > add-task-view is called in om/IRenderState#render-state of the aggregating > component ... so I was under the impression everything was implemented > similar to the contacts-view add-contact in > https://github.com/swannodette/om/wiki/Basic-Tutorial concerning the > render phases. > > ;; > ;; Event handler > ;; > (defn add-new-task [tasks owner] > (.log js/console "callback/handle-new-task" tasks) > (let [title (-> (om/get-node owner "new-task-title") .-value) > description (-> (om/get-node owner "new-task-description") > .-value) > tags (-> (om/get-node owner "new-task-tags") .-value)] > (.log js/console "new task:" title description tags) > (om/transact! tasks #(conj % (Task. "task-2" "me" "me" title > [tags] description))))) > > ;; > ;; AddActivityView > ;; https://github.com/floriansalihovic/shunyata/issues/9 > ;; > (defn add-task-view > "Component used to add new tasks." > [app owner] > (reify > ;; when not implemented, add-new-task will throw an error is > app is passed. > om/IInitState > (init-state [this] > {:tasks (:tasks(:project app))}) > > om/IRenderState > (render-state [this state] > (.log js/console "add-task-view#render-state") > (dom/div nil > (dom/h3 nil (i18n :task)) > (dom/label nil > (i18n :title) > (dom/input #js {:type "text" :ref "new-task-title"})) > (dom/label nil > (i18n :description) > (dom/input #js {:type "text" :ref "new-task-description"})) > (dom/label nil > (i18n :tags) > (dom/input #js {:type "text" :ref "new-task-tags"})) > (dom/div nil > (dom/button #js {:onClick #(add-new-task (:tasks state) > owner)} "☑")))))) > > So my question basically is: is my soluation "idiomatic/clean" solution > when creating data in Om. > > -- > 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.
