This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-02
Channels
- # adventofcode (20)
- # bangalore-clj (14)
- # beginners (72)
- # cider (2)
- # clara (2)
- # cljs-dev (8)
- # clojure (36)
- # clojure-brasil (201)
- # clojure-greece (29)
- # clojure-nl (1)
- # clojure-poland (1)
- # clojure-russia (2)
- # clojure-spec (5)
- # clojure-uk (4)
- # clojurescript (41)
- # cursive (1)
- # datomic (1)
- # emacs (6)
- # fulcro (80)
- # graphql (1)
- # klipse (2)
- # leiningen (5)
- # lumo (15)
- # off-topic (1)
- # om (3)
- # om-next (3)
- # re-frame (19)
- # reagent (7)
- # test-check (1)
- # uncomplicate (2)
- # yada (8)
@wilkerlucio sadly not. I do have my action wrapped in a function , given as value for :action
. what I meant was, my mutate function is called twice, but my action is called only once, so that's ok. it was just suspicious, and I thought it might be a clue to why I am getting this error.
@wilkerlucio Here's the code:
(ns om.test
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
(def app-state (atom {:search-text ""}))
(defmulti read om/dispatch)
(defmulti mutate om/dispatch)
(defmethod mutate `update-search-text [{:keys [state]} k {:keys [value]}]
(println "update-search-text" value)
{:action #(swap! app-state assoc :search-text value)})
(defmethod read :default [{:keys [state]} k p]
{:value (get @state k)})
(defui Customers
static om/IQuery
(query [this]
[:search-text])
Object
(render [this]
(let [{:keys [customers search-text]} (om/props this)]
;(println "Rendering Customers" (om/props this))
(dom/p nil
(dom/input #js {:value search-text
:type "text"
:onChange #(om/transact! this `[(update-search-text {:value ~(.. % -target -value)})])
}))
)))
(def customers (om/factory Customers))
(defui RootView
static om/IQuery
(query [this]
[:search-text])
Object
(render [this]
(let [{:keys [page] :as props} (om/props this)]
;(println "Rendering root" (om/props this))
(dom/div nil
(customers props)))))
(def reconciler
(om/reconciler
{:state app-state
:parser (om/parser {:read read :mutate mutate})
}))
(om/add-root! reconciler
RootView (gdom/getElement "app"))