tink_await icon indicating copy to clipboard operation
tink_await copied to clipboard

@:await JS Promises

Open piboistudios opened this issue 3 years ago • 9 comments

This will just extract the T from js.lib.Promise<T> (if it is a js.lib.Promise) and wrap the expression in a check-type statement: ($expr : tink.core.Promise<T>).

piboistudios avatar Dec 24 '21 10:12 piboistudios

I prefer having the user manually covert it via Promised.ofJsPromise

kevinresol avatar Dec 24 '21 11:12 kevinresol

I prefer having the user manually covert it via Promised.ofJsPromise

You should see my edit of the README ;)

Plus this wouldn't be a breaking change (as, this would have caused a compile-time error previously)

It's entirely optional

piboistudios avatar Dec 24 '21 11:12 piboistudios

I don't use tink_await much nowadays and I am not sure if it is good to lift everything to a Promise implicitly. I will let others to comment.

kevinresol avatar Jan 15 '22 09:01 kevinresol

@kevinresol I am not sure what your concern is? Do you want to avoid wrapping everything? I believe it is up to the dev to decide : they can either use @await and in which case it gets wrapped or if they do not want to wrap it they can just use .then on the object :)

Pign avatar Jun 17 '22 09:06 Pign

I main concern is the scope of this library. I am just not sure if we should include JS promises into our scope.

kevinresol avatar Jun 17 '22 09:06 kevinresol

Well I'd say that unification of promises to "the tink way" in the scope of a "tink framework" seems fair.

Pign avatar Jun 17 '22 09:06 Pign

I main concern is the scope of this library. I am just not sure if we should include JS promises into our scope.

I can see how the earlier edits raised some concern. But the code change now is just applying tink.core.Promise.lift to the value that needs awaiting. Which also allows any abstract X to Promise to be awaited and that is pretty nice.

benmerckx avatar Jun 17 '22 09:06 benmerckx

the code change now is just applying tink.core.Promise.lift

Oh completely missed that part. well yeah then I agree this is good.

kevinresol avatar Jun 17 '22 09:06 kevinresol

@piboistudios could you reword the doc update a little to reflect that we simply use Promise.lift as opposed to extracting things?

benmerckx avatar Jun 17 '22 09:06 benmerckx