{"action":"created","issue":{"url":"https://api.github.com/repos/alexa-js/alexa-app/issues/133","repository_url":"https://api.github.com/repos/alexa-js/alexa-app","labels_url":"https://api.github.com/repos/alexa-js/alexa-app/issues/133/labels{/name}","comments_url":"https://api.github.com/repos/alexa-js/alexa-app/issues/133/comments","events_url":"https://api.github.com/repos/alexa-js/alexa-app/issues/133/events","html_url":"https://github.com/alexa-js/alexa-app/pull/133","id":203659279,"number":133,"title":"Support Promises/callbacks from request handlers (#71)","user":{"login":"ajcrites","id":1308273,"avatar_url":"https://avatars.githubusercontent.com/u/1308273?v=3","gravatar_id":"","url":"https://api.github.com/users/ajcrites","html_url":"https://github.com/ajcrites","followers_url":"https://api.github.com/users/ajcrites/followers","following_url":"https://api.github.com/users/ajcrites/following{/other_user}","gists_url":"https://api.github.com/users/ajcrites/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcrites/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcrites/subscriptions","organizations_url":"https://api.github.com/users/ajcrites/orgs","repos_url":"https://api.github.com/users/ajcrites/repos","events_url":"https://api.github.com/users/ajcrites/events{/privacy}","received_events_url":"https://api.github.com/users/ajcrites/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-27T15:12:31Z","updated_at":"2017-01-27T15:20:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/alexa-js/alexa-app/pulls/133","html_url":"https://github.com/alexa-js/alexa-app/pull/133","diff_url":"https://github.com/alexa-js/alexa-app/pull/133.diff","patch_url":"https://github.com/alexa-js/alexa-app/pull/133.patch"},"body":"For Issue #71 \r\n\r\nThis allows you to return a Promise from a request handler (launch, intent handler, session ending, or audio player events). When the promise resolves, the response is sent. If the promise is rejected, it is treated like an error (e.g. if an error were thrown from the handler).\r\n\r\nI have written the code so that it also now supports callbacks in an asynchronous pattern:\r\n\r\n    skill.intent(\"intentName\", utterances, (req, res, cb) => {\r\n      someAsync(cb);\r\n      return false;\r\n    });\r\n\r\nCurrently you can either return a Promise or `false` from the handler in order to be asynchronous, but calling the callback makes calling `res.send` unnecessary.\r\n\r\nThis is backwards compatible, but I would be in favor of a major version change that supports _only_ promises and just using:\r\n\r\n    Promise.resolve(handlerResult).then(res.send).catch(handleError);\r\n\r\nWe can also remove the `return false` functionality and make either returning a Promise or calling the callback required in order to send the response (or just call `response.send()` explicitly). I can either do this now as part of this PR or we can move forward with this and remove backwards compatibility later."},"comment":{"url":"https://api.github.com/repos/alexa-js/alexa-app/issues/comments/275689947","html_url":"https://github.com/alexa-js/alexa-app/pull/133#issuecomment-275689947","issue_url":"https://api.github.com/repos/alexa-js/alexa-app/issues/133","id":275689947,"user":{"login":"coveralls","id":2354108,"avatar_url":"https://avatars.githubusercontent.com/u/2354108?v=3","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2017-01-27T15:20:55Z","updated_at":"2017-01-27T15:20:55Z","body":"\n[![Coverage Status](https://coveralls.io/builds/9875372/badge)](https://coveralls.io/builds/9875372)\n\nChanges Unknown when pulling **f7b5a1eef171a13a7015e61b793a7114116edd46 on ajcrites:promise/71** into ** on alexa-js:master**.\n"}}
{"actor":{"display_login":"coveralls"}}