I am working on integrating the event system with om-event-bus, it use async/chan to transfer the events. However, it turns out html DOM event failed to be transfer through clojurescript's async channel. The properties in the transferred event becomes null and the internal functions are missing.
Define a channel first:
(def event-bus (chan))
Setup a dom node and attach a callback function to the keydown event. In the function, add the put the dom event in the channel (PS:I use om as UI)
(dom/section #js {:id "VRE"
:tabIndex 0
:onKeyDown #(put! event-bus %)))
wait to receive the event transferred
(go-loop
[]
(let [e (<! event-bus)]
(when e
(println "go-loop received" (.stringify js/JSON e))
(recur))))
When I type some key, the console will print:
go-loop received {"dispatchConfig":null,
"dispatchMarker":null,
"nativeEvent":null,
"type":null,
...
"_dispatchListeners":null,"_dispatchIDs":null}
All the properties are null and the internal functions like preventDefault are missing.
I guess there must be something I haven't understood. Does anyone have some ideas for fixing it? It would be great if you could give some hints/tips or other thoughts on the problem