{"action":"created","issue":{"url":"https://api.github.com/repos/amphp/amp/issues/45","repository_url":"https://api.github.com/repos/amphp/amp","labels_url":"https://api.github.com/repos/amphp/amp/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/amphp/amp/issues/45/comments","events_url":"https://api.github.com/repos/amphp/amp/issues/45/events","html_url":"https://github.com/amphp/amp/pull/45","id":154269239,"number":45,"title":"Add the promise() function","user":{"login":"DaveRandom","id":2396425,"avatar_url":"https://avatars.githubusercontent.com/u/2396425?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveRandom","html_url":"https://github.com/DaveRandom","followers_url":"https://api.github.com/users/DaveRandom/followers","following_url":"https://api.github.com/users/DaveRandom/following{/other_user}","gists_url":"https://api.github.com/users/DaveRandom/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveRandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveRandom/subscriptions","organizations_url":"https://api.github.com/users/DaveRandom/orgs","repos_url":"https://api.github.com/users/DaveRandom/repos","events_url":"https://api.github.com/users/DaveRandom/events{/privacy}","received_events_url":"https://api.github.com/users/DaveRandom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-11T15:14:58Z","updated_at":"2016-05-11T15:25:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/amphp/amp/pulls/45","html_url":"https://github.com/amphp/amp/pull/45","diff_url":"https://github.com/amphp/amp/pull/45.diff","patch_url":"https://github.com/amphp/amp/pull/45.patch"},"body":"This is just syntactic sugar around `resolve()` for use with a generator closure to avoid temporary variables.\r\n\r\nInstead of having to write:\r\n\r\n```php\r\n$var = function() {\r\n    yield;\r\n};\r\nreturn resolve($var);\r\n```\r\n\r\nyou can simply write:\r\n\r\n```php\r\nreturn promise(function() {\r\n    yield;\r\n});\r\n```\r\n\r\nI'm not married to the function name if it doesn't suit, but this is an option I have found frustratingly missing.\r\n\r\nThis PR also adds a missing `@return` tag to the `resolve()` docblock."},"comment":{"url":"https://api.github.com/repos/amphp/amp/issues/comments/218494207","html_url":"https://github.com/amphp/amp/pull/45#issuecomment-218494207","issue_url":"https://api.github.com/repos/amphp/amp/issues/45","id":218494207,"user":{"login":"kelunik","id":2743004,"avatar_url":"https://avatars.githubusercontent.com/u/2743004?v=3","gravatar_id":"","url":"https://api.github.com/users/kelunik","html_url":"https://github.com/kelunik","followers_url":"https://api.github.com/users/kelunik/followers","following_url":"https://api.github.com/users/kelunik/following{/other_user}","gists_url":"https://api.github.com/users/kelunik/gists{/gist_id}","starred_url":"https://api.github.com/users/kelunik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelunik/subscriptions","organizations_url":"https://api.github.com/users/kelunik/orgs","repos_url":"https://api.github.com/users/kelunik/repos","events_url":"https://api.github.com/users/kelunik/events{/privacy}","received_events_url":"https://api.github.com/users/kelunik/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T15:25:09Z","updated_at":"2016-05-11T15:25:09Z","body":"Another possible solution would be to change `resolve` to accept callables and generators."}}