scittle

Richie 2022-12-16T21:10:20.083099Z

Does scittle not have clojure.core/promise? I don’t know how to make js/Promise work for me. I want to make a promise, put it somewhere, and deliver to it later.

Richie 2022-12-16T21:10:40.098159Z

:msg "{:ex \"\\\"#error {:message \\\\\\\"Could not resolve symbol: promise\\\\\\\", :data {:type :sci/error, :line 1, :column 1, :message \\\\\\\"Could not resolve symbol: promise\\\\\\\", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 1, :column 1, :ns #object[To main], :file nil})}], :file nil, :phase \\\\\\\"analysis\\\\\\\"}, :cause #error {:message \\\\\\\"Could not resolve symbol: promise\\\\\\\", :data {:type :sci/error, :line nil, :column nil, :file nil, :phase \\\\\\\"analysis\\\\\\\"}}}\\\"\", :status [\"error\" \"done\"], :id \"354\", :session \"aef012af-d259-442d-91e3-5e1712963442\", :ns \"main\"}"

Richie 2022-12-16T21:20:22.416109Z

I want to register with a websocket so that on message I deliver to the promise.

borkdude 2022-12-16T21:31:10.029689Z

You can do this like this in JS:

(js/Promise. (fn [resolve reject]
  (resolve 10)) 
You can do anything you want instead of (resolve 10) to send 10 to the part of the program that's waiting on that promise

Richie 2022-12-16T21:35:21.285669Z

Im trying to deliver it from the onmessage of a websocket that i registered before constructing the promise.

Richie 2022-12-16T21:36:59.026469Z

Sorry. Afk atm.

borkdude 2022-12-16T21:37:32.815189Z

Yeah, you can do:

(let [!resolve (atom nil) prom (js/Promise. (fn [resolve reject] (reset! !resolve resolve)))]
  (onreceive [msg] (@!resolve msg))
(pseudo-code, but you get the idea)

Richie 2022-12-16T21:56:11.246529Z

Richie 2022-12-16T21:58:18.664269Z

I’m trying to proxy http requests through my local to get around cors.

Richie 2022-12-16T22:09:21.330749Z

Taking you psuedo-code further, it would look like this.

Richie 2022-12-16T22:09:29.999239Z

Richie 2022-12-16T22:10:28.646989Z

That does seem to work. I guess I’ll just use that for now.

Richie 2022-12-16T22:11:28.945069Z

server code