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

Support collection operations #15

Closed
clue opened this issue Jul 5, 2015 · 7 comments
Closed

Support collection operations #15

clue opened this issue Jul 5, 2015 · 7 comments

Comments

@clue
Copy link
Member

clue commented Jul 5, 2015

What is the recommended way to wait for a timeout of multiple promises?

react/promise provides several promise collection primitives, which all have valid use cases.

One might assume the following is the way to go:

$promises = array(
    accessSomeRemoteResource(),
    accessSomeRemoteResource(),
    accessSomeRemoteResource()
);

$promise = \React\Promise\all($promises);

Timer\timeout($promise, 10, $loop)->then(function ($values) {
    // *all* promises resolved
});

How does this cope with cancellation support? (Refs #9 and #3)

@clue
Copy link
Member Author

clue commented Jul 5, 2015

The above example is also part of the documentation (#14). However, it does currently not describe how cancellation of promise collections works.

@jsor
Copy link
Member

jsor commented Jul 5, 2015

Cancellation of promise collections should be handled within react/promise but is currently not supported. Calling cancel() on the promise returned by all/any/some etc. could be forwarded to all promises of the collection.

@clue
Copy link
Member Author

clue commented Jul 5, 2015

Cancellation of promise collections should be handled within react/promise but is currently not supported.

Thanks the feedback! I've just filed reactphp/promise#33 to keep track of this.

@clue
Copy link
Member Author

clue commented Jul 5, 2015

In the meantime, we might consider adding helper functions like timeoutAll($promises) etc.?

@jsor
Copy link
Member

jsor commented Jul 5, 2015

I think we should better invest the time to implement this cleanly in react/promise. Will look at it in the next week.

@jsor
Copy link
Member

jsor commented Jul 6, 2015

See reactphp/promise#36

@clue
Copy link
Member Author

clue commented Apr 6, 2017

I agree that it makes more sense to keep relying on promise primitives instead of duplicating similar logic here 👍

I'll assume this is resolved and will close this for now, please feel free to report back otherwise 👍

@clue clue closed this as completed Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants