funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
niwinz 2016-08-25T06:00:00.000094Z

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

1👍
niwinz 2016-08-25T06:00:18.000095Z

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

2016-08-25T14:45:16.000097Z

@kingoftheknoll o/

2016-08-25T14:45:19.000098Z

yo

2016-08-25T14:45:30.000099Z

forget about my response earlier, i misunderstood the question

2016-08-25T14:45:57.000100Z

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

2016-08-25T14:47:47.000103Z

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

2016-08-25T14:50:01.000105Z

the second seems more appropriate. So would that be…

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

2016-08-25T14:50:51.000106Z

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

2016-08-25T15:01:10.000107Z

@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

2016-08-25T15:27:39.000108Z

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

2016-08-25T15:28:25.000109Z

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

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

2016-08-25T15:28:56.000110Z

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

2016-08-25T15:29:03.000111Z

i believe is what you want

2016-08-25T17:54:41.000114Z

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

2016-08-25T17:55:46.000115Z

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

2016-08-25T19:57:10.000117Z

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

2016-08-25T21:37:28.000121Z

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

2016-08-25T22:47:49.000122Z

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

2016-08-25T22:59:48.000125Z

@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