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

feat(async): introduce more async helper functions #291

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

azjezz
Copy link
Owner

@azjezz azjezz commented Dec 1, 2021

Signed-off-by: azjezz azjezz@protonmail.com

@azjezz azjezz added Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes. labels Dec 1, 2021
@azjezz azjezz added this to the 2.0.0 milestone Dec 1, 2021
@azjezz azjezz self-assigned this Dec 1, 2021
@azjezz
Copy link
Owner Author

azjezz commented Dec 1, 2021

@veewee stuff you like ;)

Signed-off-by: azjezz <azjezz@protonmail.com>
@coveralls
Copy link

coveralls commented Dec 1, 2021

Pull Request Test Coverage Report for Build 1527704153

  • 30 of 30 (100.0%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 99.97%

Files with Coverage Reduction New Missed Lines %
src/Psl/Async/first.php 1 85.71%
Totals Coverage Status
Change from base Build 1527228788: -0.03%
Covered Lines: 3304
Relevant Lines: 3305

💛 - Coveralls

@azjezz azjezz merged commit 9423928 into 2.0.x Dec 1, 2021
@azjezz azjezz deleted the feat/async-helpers branch December 1, 2021 20:47
@veewee
Copy link
Collaborator

veewee commented Dec 1, 2021

Nice stuff!
Looks like amp is taking a slightly different approach in v3. But at the moment, I prefer the helpers in here over launching futures. It might be habit though 🙂

@azjezz
Copy link
Owner Author

azjezz commented Dec 1, 2021

well, the good thing is that they can be used together!

use Amp;
use Amp\Future;
use Psl\Async;
use Psl\Shell;
use Psl\Result;

/**
 * @var Result\ResultInterface<string> $result1
 * @var Result\ResultInterface<string> $result2
 */
[$result1, $result2] = Amp\Future\all(
  Amp\launch(Async\reflect(fn() => Shell\execute('foo'))),
  Amp\launch(Async\reflect(fn() => Shell\execute('foo'))),
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants