-
Notifications
You must be signed in to change notification settings - Fork 591
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
core: make operations promise friendly #1689
core: make operations promise friendly #1689
Conversation
* | ||
* @return {promise} | ||
*/ | ||
GrpcOperation.prototype.promise = function() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* // An error occurred during the job. | ||
* }); | ||
*/ | ||
Job.prototype.promise = function() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Idea and code lgtm. |
Job.prototype.promise = function() { | ||
var self = this; | ||
|
||
return new common.util.Promise(function(resolve, reject) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@stephenplusplus tests have been added, PTAL! |
var self = this; | ||
|
||
return new self.Promise(function(resolve, reject) { | ||
self.on('error', reject) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
var self = this; | ||
|
||
return new self.Promise(function(resolve, reject) { | ||
self.on('error', reject) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This makes operations Promise friendly. By default they are still
EventEmitter
instances, but now include a.promise()
method as a convenience.With Bluebird
In Node >= 6.0: