Liking cljdoc? Tell your friends :D

Cljs Synchronous Promise

Handy when you want to keep tests synchronous.

Clojars Project

Tests build

this is only a partial impl atm. There's this pure js one if you need more

Usage

Fake the sources of your js/Promises (e.g. http calls) to return sync promises

(require '[com.widdindustries.synchronous-promise :as sp])

(-> (sp/resolved :val)
      (.then (fn [v] [v]))
      (.catch (fn [_] (throw (js/Error. "never called"))))
      (.then (fn [x] (js/console.log x) x)))

; make it work with promesa fns
(promesa.impl/extend-promise! sp/SyncPromise) 
(set! promesa.impl/*default-promise* sp/SyncPromise)

see the test nss for more examples

license

Copyright © 2020 Widd Industries Ltd

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close