Skip to content

Add void promise - #270

Merged
Oipo merged 1 commit into
apache:masterfrom
Oipo:feature/void_promise
Aug 10, 2020
Merged

Add void promise#270
Oipo merged 1 commit into
apache:masterfrom
Oipo:feature/void_promise

Conversation

@Oipo

@Oipo Oipo commented Jul 17, 2020

Copy link
Copy Markdown
Contributor

There's a lot of code duplication, so I can imagine that there will be plenty of comments.

The only question I have remaining is the Promise<void> resolveWith(Promise<T> with); function. Can someone create a test showing the use of such a function?

@Oipo Oipo mentioned this pull request Jul 20, 2020
@pnoltes

pnoltes commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

There's a lot of code duplication, so I can imagine that there will be plenty of comments.

The only question I have remaining is the Promise<void> resolveWith(Promise<T> with); function. Can someone create a test showing the use of such a function?

Promise can be used as way to see if something is done (ok or nok (onResolve on onFailure).

The use case for resolving a void promise with a typed promise is (IMO) if you are not interested in the result downstream, but use want to use the promise as a sync.

So for example you get Promise from some function (maybe 3rd party) where the double is the time it took to process, but in "our" API we just want to indicate whether were a done (success or failed). In this case you can create a Promise and resolve it with the Promise (regardless if the Promise is already resolved or not)

@pnoltes
pnoltes self-requested a review July 22, 2020 18:55
@Oipo
Oipo merged commit eb8862e into apache:master Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants