This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-05
Channels
- # announcements (1)
- # beginners (72)
- # boot (4)
- # calva (35)
- # cider (8)
- # clara (13)
- # cljdoc (31)
- # cljs-dev (34)
- # clojure (64)
- # clojure-europe (1)
- # clojure-finland (3)
- # clojure-italy (23)
- # clojure-losangeles (3)
- # clojure-nl (35)
- # clojure-uk (19)
- # clojurescript (26)
- # cursive (19)
- # datomic (12)
- # duct (5)
- # editors (7)
- # emacs (25)
- # fulcro (40)
- # funcool (5)
- # jobs (2)
- # leiningen (3)
- # luminus (2)
- # lumo (3)
- # off-topic (19)
- # pathom (3)
- # planck (2)
- # reagent (6)
- # remote-jobs (4)
- # rum (1)
- # shadow-cljs (23)
- # spacemacs (6)
- # tools-deps (12)
Hi, I'm have a question about using promesa async/await in clojurescript(in node). I have this function:
(defn get-json [url]
(let [result
(async
(dotimes [i 3]
(p/await (p/delay 100))
(println "i=" i))
[{:a "hello"}])]
@result
)
And I required
[promesa.core :as p]
[promesa.async-cljs :refer-macros [async]]
However, when I call get-json
I'm getting an error:
(montaigne.fns/get-json "aa")
Execution error (Error) at (<cljs repl>:1).
No protocol method IDeref.-deref defined for type object: [object Promise]
Any hints? It should be possible to have synchronous looking code in ClojureScript running in node, right?@podviaznikov cljs promesa doesn't support deref
aka @
- once you are in async-land, there is no escape!
(instead of deref
ing, compose further then
actions onto your promises)
yeah, makes sense. Thanks 🙏 I wish there was escape:)
Ok, There might be sync http request in node. https://www.npmjs.com/package/sync-request. I'm writing CLI, so for me sync requests are fine, no need for async io