-
-
Save coldnew/3ddb961a8f2aac73d75886d0b87e3f8b 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