X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=examples%2Fpromise.php;h=e1f5b9d4fbd4a3311e322fe2706d6ffa11423928;hb=cac6bea94e6cde142c951566fa6387ffa54eb3cb;hp=c26e91131fee05377d99e8cf6ab74b8b159d3901;hpb=f4aa6beaf2e1f0dc9c877782cbbad5a989194517;p=m6w6%2Fseekat diff --git a/examples/promise.php b/examples/promise.php index c26e911..e1f5b9d 100755 --- a/examples/promise.php +++ b/examples/promise.php @@ -4,16 +4,14 @@ require_once __DIR__."/../vendor/autoload.php"; use seekat\API; -use seekat\API\Future; -$log = new Monolog\Logger("seekat"); -$log->pushHandler((new Monolog\Handler\StreamHandler(STDERR))->setLevel(Monolog\Logger::NOTICE)); +$api = new API(API\Future\amp(), API\auth("token", getenv("GITHUB_TOKEN"))); -$api = new API(Future\amp(), API\auth("token", getenv("GITHUB_TOKEN")), null, null, $log); - -$api->users->m6w6->gists()->when(function($error, $gists) { +$api->users->m6w6->gists()->onResolve(function($error, $gists) { + $error and die($error); foreach ($gists as $gist) { - $gist->commits()->when(function($error, $commits) use($gist) { + $gist->commits()->onResolve(function($error, $commits) use($gist) { + $error and die($error); foreach ($commits as $i => $commit) { if (!$i) { printf("\nGist %s, %s:\n", $gist->id, $gist->description ?: "");