Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns opnenablement.ui
(:require-macros
[cljs.core.async.macros :refer [go]]
[shoreleave.remotes.macros :as srm]
[dommy.macros :refer [sel sel1]])
(:require
[cljs.core.async :refer [>! <! alts! puts! put! chan timeout dropping-buffer]]
[shoreleave.remotes.http-rpc :as srh]
[dommy.core :as dommy]))
(defn listen [chan el type])
(binding [srh/*remote-uri* "/opnenablement/_shoreleave"]
(let [dirty_c (chan (dropping-buffer 1))
save_c (chan)
out (sel1 :#out)
]
(defn on-input [e]
(dommy/set-text! out "DIRTY! ")
(put! dirty_c :dirty))
(defn on-blur [e]
(dommy/set-text! out "BLUR! ")
(put! save_c :save))
(go (while true
(let [e (<! dirty_c)]
(dommy/set-text! out "SAVED!")
;;; this does not work, goes to /_shoreleave
;;; allmost regardless of where the (binding ... is
(srm/rpc (save-config "myConfig") [result]
:on-success (js/alert (str "Success: " result))
:on-error (js/alert (str "Error: " result)))
(alts! [save_c (timeout 2000)]))))))
(defn ^:export init []
(.log js/console "Hey!")
(dommy/listen! (sel1 :#inputProdukte)
:input on-input)
(dommy/listen! (sel1 :#inputProdukte)
:onblur on-blur)
(binding [srh/*remote-uri* "/opnenablement/_shoreleave"]
;;; this works as expected, goes to /opnenablement/_shoreleave
(srm/rpc (save-config "myConfig") [result]
:on-success (js/alert (str "Success: " result))
:on-error (js/alert (str "Error: " result)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.