hoplon / castra

HTTP remote procedure call handler for Clojure.
172 stars 25 forks source link

use worker threads to make ajax requests, introduce cljs futures, and eliminate jquery dependency #19

Open jumblerg opened 8 years ago

jumblerg commented 8 years ago

castra uses jquery for its (a) ajax fn and (b) promise. this dependency can be removed by (1) using the native XMLHttpRequest (2) making requests from a worker thread wrapped in a clojurescript future abstraction.

(defn xhr [{:keys [url credentials headers body]}]
  (doto (js/XMLHttpRequest.)
        (.open "POST" url false)
        (set-req-headers headers)
        (aset "withCredentials" credentials)
        (.send body)))
jumblerg commented 8 years ago

ref http://www.html5rocks.com/en/tutorials/workers/basics/#toc-inlineworkers