-
Notifications
You must be signed in to change notification settings - Fork 92
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
Update Strong-remoting API docs for promises #276
Comments
@davidcheung @jannyHou this is still relevant, although possibly in a different way than was originally meant.
These two methods accept an async handler function that is called for every request. This handler function signal the completion either by accepting a callback argument, as is currently shown in our API docs; or it can return a promise. // current example
remotes.after('dog.prototype.speak', function(ctx, next) {
console.log('After speak!');
next();
});
// promise version
remotes.after('dog.prototype.speak', function(ctx) {
console.log('After speak!');
return Promise.resolve();
});
This is an internal method that intentionally does not support Promise mode, there is no need to change the current API docs (IMO). |
@bajtos Thank you for confirming, Makes sense now. |
@jannyHou I think it still makes sense to improve the doc and show how to write a handler function returning a promise. remotes.before('dog.prototype.speak', function(ctx) {
console.log('Before speak!');
return Promise.resolve();
});
remotes.after('dog.prototype.speak', function(ctx) {
console.log('After speak!');
return Promise.resolve();
}); |
oh ok lol @bajtos I will update the doc then. just keep the APIs doc as before. |
Closing as resolved |
Parent: strongloop/loopback/issues/1409
Related: strongloop/strong-docs/issues/63, strongloop-internal/scrum-loopback/issues/615
lib/remote-objects.js
RemoteObjects.after
RemoteObjects.before
lib/shared-method.js
sharedMethod.invoke
The text was updated successfully, but these errors were encountered: