Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Promise combinators and determinism concerns #312

Merged
merged 5 commits into from
Mar 5, 2024
Merged

Conversation

gvdongen
Copy link
Contributor

@gvdongen gvdongen commented Mar 4, 2024

Fixes #307

  • Documents CombineablePromise.all/any/allSettled/race for TS
  • Documents Awaitable.any/all for Java
  • Adds note on determinism concerns when not awaiting side effects

@gvdongen gvdongen requested a review from slinkydeveloper March 4, 2024 15:17
Copy link

cloudflare-workers-and-pages bot commented Mar 4, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: c732728
Status: ✅  Deploy successful!
Preview URL: https://e5e97dc5.documentation-beg.pages.dev
Branch Preview URL: https://issue307.documentation-beg.pages.dev

View logs

Comment on lines 289 to 297
Creates an Awaitable that awaits all of the provided Awaitables to resolve.

**Awaitable.any():**

```shell
SomeResponse res = (SomeResponse) Awaitable.any(a1, a2, a3).await();
```

Creates an Awaitable that awaits any of the provided Awaitables to resolve.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write down the the behaviour is similar to JDK's CompletableFuture.all/any

**Awaitable.all():**

```shell
SomeResponse res = (SomeResponse) Awaitable.all(a1, a2, a3).await();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, SomeResponse returns Void.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to then do Awaitable#await on the single awaitables (where the operation will be no-op because the value was awaited by await all)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slinkydeveloper Can you suggest what it should be? I am not sure what you mean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaitable.all(a1, a2, a3).await();

SomeResponse a1Res = a1.await(); // This immediately returns value

Something like that


**CombineablePromise.allSettled():**

```shell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be typescript? same below with java?

@gvdongen gvdongen merged commit 8871b64 into main Mar 5, 2024
2 checks passed
@gvdongen gvdongen deleted the issue307 branch March 5, 2024 08:42
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.

Document combineable promises
2 participants