Casting any yielded value to a task automatically in GeneratorTask

Merged
#1 · Created  · Last updated

Merged pull request

Merged in moufmouf/async (pull request #1)

a44b93f·Author: ·Closed by: ·2014-09-25

Description

Hi Matt!

First of all, congrats for this great library! I found "async" after reading the blog article from Nikic about the use of the "yield" keyword, and I'm still pretty new to all this.

I did a few tests with your lib. I think I'm starting to get a good grip on it. I was wondering one thing though. It is kind of tedious to cast everything to a "Task" before yielding it.

Most of the time, I'm yielding values, or promises, or callbacks...

Therefore, I tried to cast the value passed to "yield" into the GeneratorTask. This way, the burden is on the lib rather than on the developer.

Instead of doing:

$result = (yield Util::async($resultTask));

I can now write:

$result = (yield $resultTask);

Does it sound a good idea to you or is there a particular reason why you chose not to do it?

Anyway, thanks for this lib, it is great being able to do some async stuff that looks synchronous :)

0 attachments

0 comments

Loading commits...