Clojure's equlivalent to a jQuery Deferred? -


clojure has promise, future, delay, etc. none semantically similar deferred object in jquery. block if dereferenced before value available. deferred objects utilize callbacks. clojure (not clojurescript) offer similar jquery deferred?

you can use other clojure constructs you're looking for, don't think there's in core clojure similar.

as simple example, uses future provides computed value provided callback function:

(defn deferred [func cb]   (future (let [v (func)]             (cb v))))  ;; (deferred #(do (thread/sleep 1000) 7) #(println %)) 

you add special exception handling, , use future-done? check whether value ready without blocking, , more. (callback-oriented approaches asynchronous behavior excellent in circumstances, if haven't experimented other approaches clojure offers might find them well-suited too.)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -