-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Amp Pattern Question #63
Labels
Comments
You can either use <?php
function query($query) {
/* Send query */
$inFlight[$token] = new Amp\Deferred;
return Amp\pipe($inFlight[$token]->promise(), function($data) use (...) {
return ...;
}
} <?php
function query($query) {
return Amp\resolve(function () use ($query) {
$result = yield rawQuery(...);
return transformRawQuery($result);
});
} |
Thanks for the quick response! Works like a charm. |
Awesome! // closing as resolved. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm rewriting a db driver to use Amp 1.x in Aerys. It's pretty straight forward, except that I hit a wall with how promises are implemented. Here's some example code that shows my issue:
However,
$data
inmyCoRoutine
holds the results of the original response from the server, before being transformed. Do you have any tips on how to get the result from thewhen
in thequery()
function, instead of from the watcher?The text was updated successfully, but these errors were encountered: