Fork me on GitHub
#funcool
<
2016-08-25
>
niwinz06:08:00

Hmm, I think I'll go to start port buddy to nodejs.

niwinz06:08:18

there are no real and good library for crypto and jws/jwe/jwt for js 😞

dialelo14:08:30

forget about my response earlier, i misunderstood the question

dialelo14:08:57

for customizing the creation of xhr objects, you can provide your own XhrIo implementation

dialelo14:08:47

alternatively, you can call methods on the default XhrIO object, for instance .setWithCredentials()

kingoftheknoll14:08:01

the second seems more appropriate. So would that be…

(.setWithCredentials ‘httpurr.client.xhr/*xhr-impl*)

kingoftheknoll14:08:51

does that mean that it’s not constructing a new XhrIo object each time it’s used?

kingoftheknoll15:08:10

@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

dialelo15:08:39

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

dialelo15:08:25

about the second idea, it'd be something like:

(.setWithCredentials httpurr.client.xhr/*xhr-impl* true)

dialelo15:08:56

this will make all Xhr objects created by XhrIo have the credentials flag set to true

dialelo15:08:03

i believe is what you want

dialelo17:08:41

yep, note that *xhr-impl* expects an instance of XhrIo, so you should bind it to the result of calling MyXhrIo

dialelo17:08:46

also be aware that .setWithCredentials doesn't return the XhrIo instance

kingoftheknoll19:08:10

@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.

dialelo21:08:28

haven't used with-bindings before, you can do (binding [httpurr.client.xhr.*xhr-impl* (MyXhrIo) ...)

kingoftheknoll22:08:49

@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.