Created
November 16, 2015 19:31
-
-
Save moea/63d7a882e4ad333f3b5a to your computer and use it in GitHub Desktop.
Get, e.g. cljs-http or any goog.net.XmlHttp-based client working on Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ... | |
(:import [goog.net XmlHttp XmlHttpFactory]) | |
(:require [cljs.nodejs :as nodejs])) | |
(def xml-http-request | |
(-> (nodejs/require "xmlhttprequest") | |
(.. -XMLHttpRequest))) | |
(defn NodeXhrFactory [] | |
(this-as this (.call XmlHttpFactory this))) | |
(goog/inherits NodeXhrFactory XmlHttpFactory) | |
(set! | |
(.. NodeXhrFactory -prototype -createInstance) | |
#(xml-http-request.)) | |
(set! | |
(.. NodeXhrFactory -prototype -internalGetOptions) | |
(constantly #js {})) | |
(defn set-global-xhr-factory! [] | |
(.setGlobalFactory XmlHttp (NodeXhrFactory.))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment