Hi everyone... I'm trying to create a simple controlled component that's linked
to app-state. It appears this is a bit of a complicated issue in Om due to the
refresh model.
Here is the logic I wrote to restrict the size of a component to 10 characters,
which doesn't work:
(defonce app-state (atom {:text "foo"}))
(om/root
(fn [data owner]
(reify om/IRender
(render [_]
(dom/input #js {
:value (:text data)
:onChange (fn [e]
(om/update! data
[:text]
(subs (.-value (.-target e)) 0 10)))}))))
app-state
{:target (. js/document (getElementById "app"))})
Reading issues such as (https://github.com/omcljs/om/issues/262) it appears
this is a known problem. (Note however that I want to link the component to
app-state, whereas the issue report deals with component-local state).
I am confused at this point what the proper workaround is for this- Is it to
simply plop an explicit "om/refresh!" call in the onChange handler? Or, is
there a better fix? Any tips are greatly appreciated!
--
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.