在下面的代码中,我调度了两个点击事件:
;; event
(reg-event-db
:some
(fn [db [_ some-val]]
(prn "The db is" db)
(assoc db :some some-val)
))
;; another event
(reg-event-db
:another
(fn [db [_ another-val]]
(prn "The db is" db)
(assoc db :another another-val)
))
;; button
[:input {:type "button" :value "Button"
:on-click #(do
(dispatch [:some :some-val])
(dispatch [:another :another-val]))}]
但是不是打印数据库映射,而是打印"The db is" #object[Object [object Object]]
,然后
Error: No protocol method IAssociative.-assoc defined for type object: [object Object]
我究竟做错了什么?我也尝试过,#(dispatch [:some :some-val :another another-val]
但这给出了同样的错误。一般来说,如何正确调度两个事件?