Skip to content
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

Closed
davidcheung opened this issue Jan 27, 2016 · 5 comments
Closed

Update Strong-remoting API docs for promises #276

davidcheung opened this issue Jan 27, 2016 · 5 comments

Comments

@davidcheung
Copy link
Contributor

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

@davidcheung davidcheung self-assigned this Jan 27, 2016
@davidcheung davidcheung added this to the #Epic: Promise-fy milestone Jan 27, 2016
@jannyHou jannyHou assigned jannyHou and unassigned davidcheung Feb 8, 2016
@0candy 0candy added #plan and removed #sprint2 labels Feb 8, 2016
@bajtos bajtos added #tob and removed #plan labels Mar 3, 2016
@jannyHou jannyHou self-assigned this Mar 31, 2016
@bajtos bajtos added #plan and removed #tob labels Apr 14, 2016
@bajtos
Copy link
Member

bajtos commented Apr 18, 2016

@davidcheung @jannyHou this is still relevant, although possibly in a different way than was originally meant.

RemoteObjects.after
RemoteObjects.before

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();
});

sharedMethod.invoke

This is an internal method that intentionally does not support Promise mode, there is no need to change the current API docs (IMO).

@jannyHou
Copy link
Contributor

@bajtos Thank you for confirming, Makes sense now.
I am closing this issue since doc is not needed.

@jannyHou jannyHou removed the #plan label Apr 18, 2016
@bajtos bajtos reopened this Apr 18, 2016
@bajtos
Copy link
Member

bajtos commented Apr 18, 2016

@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();
});

@jannyHou
Copy link
Contributor

jannyHou commented Apr 18, 2016

oh ok lol @bajtos I will update the doc then. just keep the APIs doc as before.
Will update here: https://docs.strongloop.com/display/APIC/Strong+Remoting

@dhmlau
Copy link
Member

dhmlau commented Oct 8, 2018

Closing as resolved

@dhmlau dhmlau closed this as completed Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants