This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-25
Channels
- # admin-announcements (3)
- # alda (2)
- # beginners (10)
- # boot (44)
- # cider (31)
- # cljs-dev (5)
- # cljsjs (2)
- # cljsrn (17)
- # clojure (181)
- # clojure-austin (2)
- # clojure-brasil (18)
- # clojure-canada (1)
- # clojure-conj (5)
- # clojure-dev (11)
- # clojure-gamedev (30)
- # clojure-russia (380)
- # clojure-spec (50)
- # clojure-uk (35)
- # clojurescript (146)
- # clojutre (1)
- # component (1)
- # cursive (62)
- # datomic (27)
- # dirac (7)
- # editors (23)
- # emacs (7)
- # events (34)
- # funcool (22)
- # hoplon (134)
- # jobs (22)
- # jobs-rus (7)
- # juxt (1)
- # kekkonen (1)
- # lein-figwheel (54)
- # leiningen (7)
- # luminus (2)
- # off-topic (5)
- # om (4)
- # onyx (27)
- # proton (5)
- # protorepl (2)
- # re-frame (16)
- # reagent (29)
- # rethinkdb (2)
- # schema (1)
- # untangled (61)
- # yada (9)
for customizing the creation of xhr objects, you can provide your own XhrIo
implementation
alternatively, you can call methods on the default XhrIO
object, for instance .setWithCredentials()
the second seems more appropriate. So would that be…
(.setWithCredentials ‘httpurr.client.xhr/*xhr-impl*)
does that mean that it’s not constructing a new XhrIo object each time it’s used?
@dialelo ok I misunderstood that. It looks like the reify constructs a new XhrIo object but I’m not sure at what point I can call the method on it. Because the return value of the send! function is a promise at that point and the request is already in flight. You’ll have to forgive me I’m not terribly familiar with the interop/reify stuff
don't worry @kingoftheknoll, you're right in that you can't call methods on the xhr
of the reified object since the request is i flight
about the second idea, it'd be something like:
(.setWithCredentials httpurr.client.xhr/*xhr-impl* true)
this will make all Xhr objects created by XhrIo have the credentials flag set to true
yep, note that *xhr-impl*
expects an instance of XhrIo
, so you should bind it to the result of calling MyXhrIo
@dialelo just getting back to this, looks like with-bindings doesn’t exist in clojurescript. Not entirely sure what to use to do the binding. BTW ^ changed the constructor to...
(defn MyXhrIo []
(doto (goog.net.XhrIo.)
(.setWithCredentials true)))
which will return the object.haven't used with-bindings
before, you can do (binding [httpurr.client.xhr.*xhr-impl* (MyXhrIo) ...)
@dialelo the binding works but now I’m getting the error httpurr.client.xhr._STAR_xhr_impl_STAR_.send is not a function
. So right here https://github.com/funcool/httpurr/blob/master/src/httpurr/client/xhr.cljs#L72 it’s trying to actually call send (which looks like a static method) on on the object I already instantiated. This feels like Russian nesting dolls here because to set withCredentials you need to instantiate but to send it must be static. So looking at the line I linked above I don’t see how it’s possible to do it.
@dialelo here’s the XhrIo code that shows withCredentials is an argument. https://github.com/google/closure-library/blob/master/closure/goog/net/xhrio.js#L330