-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[v5] Awaitable actors #3977
[v5] Awaitable actors #3977
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b71269e:
|
} | ||
|
||
// thenable | ||
public then( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't "feel" this feature. If anything, I'd probably prefer smth like toPromise
over this. Sure, we can make things "thenable" - should we though? The actor is not a promise and despite the fact that JS allows us to do this, it feels rather weird.
Since we already have waitFor
I also don't necessarily feel the need for toPromise
either. It's already simple to do this. Yet a different option would be to just have actor.waitFor
.
Our ActorLogic
interface starts to be fatter than a turkey on Thanksgiving 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current problem is there's no easy way to have "wait for actor to complete" for any actor logic, unless you're okay with an optional selector here:
// single argument - wait for actor to be done
const output = await waitFor(someActor);
// current behavior
// PROBLEM: not sure what should be returned
const output = await waitFor(someActor, state => /* ??? */);
What do you think would be a good workaround with waitFor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @Andarist - need a good solution to this use-case:
// get actor output when the actor is completed
const output = await toPromise(actor);
Can't do this with waitFor()
.
Superseded by #4198 |
This PR makes actors thenable; awaiting an actor will wait for output.