This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-03
Channels
- # announcements (2)
- # babashka (154)
- # beginners (63)
- # calva (4)
- # cider (2)
- # clara (19)
- # clj-kondo (94)
- # cljfx (8)
- # cljs-dev (6)
- # clojars (2)
- # clojure (82)
- # clojure-australia (1)
- # clojure-europe (134)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-serbia (11)
- # clojure-taiwan (1)
- # clojure-uk (39)
- # clojurescript (83)
- # community-development (108)
- # conjure (10)
- # cursive (32)
- # data-oriented-programming (1)
- # datomic (22)
- # defnpodcast (9)
- # depstar (4)
- # docker (3)
- # events (3)
- # figwheel-main (2)
- # funcool (9)
- # graalvm (19)
- # honeysql (23)
- # jackdaw (4)
- # jobs (4)
- # jobs-discuss (2)
- # kaocha (24)
- # leiningen (1)
- # lsp (12)
- # membrane (6)
- # off-topic (21)
- # pathom (13)
- # polylith (1)
- # releases (7)
- # remote-jobs (2)
- # reveal (8)
- # ring (7)
- # sci (2)
- # shadow-cljs (9)
- # sql (10)
- # tools-deps (21)
Hi, I’m trying to use promesa in a ClojureScript project targeting React Native but I have some issues where documentation does not help. On the JVM the following core works fine, but when executing in ClojureScript on device I get an error:
(require '[promesa.core :as p])
=> nil
(p/resolved? (p/promise 42))
=> #object[Error Error: No protocol method IState.-resolved? defined for type object: [object Object]]
But what about
@(p/promise 42)
=> #object[Error Error: No protocol method IDeref.-deref defined for type object: [object Object]]
The documentation says the @
reader macro does only work on the JVM, but deref
is not working, too:
(deref (p/promise 42))
=> #object[Error Error: No protocol method IDeref.-deref defined for type object: [object Object]]
When developing in the REPL I’d like to wait synchronously a promise to return its value…
@
is just sugar for deref
- neither will work in cljs because there is only a single thread in javascript, and if you block it the world stops
you can do something like
(defn grab [p]
(let [v-a (atom nil)]
(p/handle p
(fn [s f]
(reset! v-a [s f])))
v-a))
then deref the atom
Thanks@U0524B4UW … oh, right. Of course… can not work in JavaScript. Stupid me 🙈. My current solution is what you suggested with the atom… works fine.