Fork me on GitHub
#scittle
<
2022-12-17
>
ray11:12:32

You can also use promesa with scittle

borkdude11:12:02

@U04V5V0V4 His question was about this pattern:

(let [[promise resolve reject] (js/Promise. (fn [resolve reject] ...))]
  (resolve 10)
  ;; promise is resolved now)
So being able to resolve the promise from outside of the promise. I've done this in the past by closing over an atom and then storing the resolve function in the atom so you can use it outside of the promise function body

borkdude11:12:09

Does promesa support that pattern somehow?

ray12:12:31

I use a reagent atom to manage state which is updated by fetch. Then the ui reacts to the atom update.

Richie20:12:50

@U04V15CAJ I didn’t think about capturing resolve like that. I think that’s what I wanted.

Richie20:12:43

@U04V5V0V4 I think what’s different is that you make a new fetch each time but I didn’t want to make a new websocket each time.

ray22:12:08

Sure, that would be weird 😉

niwinz06:12:49

yep, is called, (p/deferred) (sorry for late response)

👍 1
niwinz06:12:19

in response to: "Does promesa support that pattern somehow?"

(let [promise (d/deferred)]
  (p/resolve! promise 10)
  promise)

👍 1
Richie15:12:03

Ah, cool! Thanks!

borkdude15:12:25

Promesa rocks metal

❤️ 1