This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-22
Channels
- # 100-days-of-code (1)
- # adventofcode (21)
- # announcements (2)
- # beginners (44)
- # calva (1)
- # cider (2)
- # cljdoc (16)
- # cljs-dev (70)
- # cljsrn (29)
- # clojure (66)
- # clojure-austria (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-nl (3)
- # clojure-uk (127)
- # clojurescript (30)
- # core-typed (3)
- # cursive (34)
- # data-science (2)
- # datomic (16)
- # duct (17)
- # editors (1)
- # emacs (4)
- # figwheel-main (4)
- # fulcro (40)
- # hoplon (2)
- # instaparse (5)
- # kaocha (4)
- # leiningen (1)
- # luminus (4)
- # nrepl (46)
- # off-topic (5)
- # onyx (2)
- # other-languages (55)
- # parinfer (3)
- # protorepl (4)
- # re-frame (33)
- # reagent (6)
- # reitit (13)
- # ring-swagger (5)
- # shadow-cljs (26)
- # spacemacs (4)
- # sql (8)
- # testing (27)
- # tools-deps (21)
- # yada (1)
@fabrao We have a helper function that puts the results of a promise on a core.async channel:
(defn promise->chan
"Takes a promise and a tag and returns a channel instead
Puts on the channel: [tag error/nil result/nil]"
[promise tag]
(let [ch (async/chan)]
(-> promise
(.then #(async/put! ch [tag % nil]))
(.catch #(async/put! ch [tag nil %])))
ch))
Then we have a normal core.async workflow using those channels.tip: if you use a async/promise-chan
you can also get the promise semantics (always output same value once its ready)
@U066U8JQJ Nice!
But for quick stuff you can just thread it through .then
and .catch
like normal js-interop
I did it but no results, like this
(.then
(.allDocs @local-database #js {:include_docs true :limit nil})
#(js/console.log (.-rows %))
)
I’d add a catch statement as well. But other than that it looks good. So there’s probably an error somewhere in your usage of the AsyncStorage API
(->
(.allDocs @local-database #js {:include_docs true :limit nil})
(.then #(js/console.log (.-rows %)))
(.catch #(js/console.log %)))
the log never came to logNo idea, but I’d start with setting the data at least so that I know there’s something there
@fabrao Also, @pesterhazy did a great talk where he explores the different concurrency models in js/cljs: https://www.youtube.com/watch?v=rV1gTJ2wsZg