{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/840","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/840/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/840/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/840/events","html_url":"https://github.com/petkaantonov/bluebird/issues/840","id":114433974,"number":840,"title":"Best practice for exposing promisifyable methods","user":{"login":"Dignifiedquire","id":790842,"avatar_url":"https://avatars.githubusercontent.com/u/790842?v=3","gravatar_id":"","url":"https://api.github.com/users/Dignifiedquire","html_url":"https://github.com/Dignifiedquire","followers_url":"https://api.github.com/users/Dignifiedquire/followers","following_url":"https://api.github.com/users/Dignifiedquire/following{/other_user}","gists_url":"https://api.github.com/users/Dignifiedquire/gists{/gist_id}","starred_url":"https://api.github.com/users/Dignifiedquire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dignifiedquire/subscriptions","organizations_url":"https://api.github.com/users/Dignifiedquire/orgs","repos_url":"https://api.github.com/users/Dignifiedquire/repos","events_url":"https://api.github.com/users/Dignifiedquire/events{/privacy}","received_events_url":"https://api.github.com/users/Dignifiedquire/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-31T20:56:40Z","updated_at":"2015-10-31T22:36:06Z","closed_at":"2015-10-31T22:36:06Z","body":"I have a question on what's the best way for me to write an API that is compatible with `promisifyAll`.\r\nAt the moment it is written in this style\r\n\r\n```js\r\nfunction API () {\r\n  this.do = function (arg1, cb) {\r\n    // do things\r\n    cb(null, res)\r\n  }\r\n  this.nested.do = function (arg2, cb) {\r\n    // do things\r\n   cb(null, res)\r\n  }\r\n}\r\n\r\n// usage\r\nvar api = new API()\r\napi.do('hello', function (err, res) {...})\r\napi.nested.do('world', function (err, res) {...})\r\n```\r\n\r\nNow this does not work with `promisifyAll` and I understand why (not using prototype, nested objects). But even if I change it to use `API.prototype` to assign the methods I still can't get the `api.nested.do` to be promisifed. Any ideas on how to solve this?"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/152778528","html_url":"https://github.com/petkaantonov/bluebird/issues/840#issuecomment-152778528","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/840","id":152778528,"user":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T22:36:06Z","updated_at":"2015-10-31T22:36:06Z","body":"You need to call promisifyAll on the nested object too. Also this issue tracker is only for bug reports or feature requests, questions about usage should be in stack overflow or the mailing list."}}