Skip to content

Commit

Permalink
Use a promise with two then()
Browse files Browse the repository at this point in the history
  • Loading branch information
srguiwiz committed May 22, 2015
1 parent 381d583 commit 5349520
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/models/thing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@ loopback = require('loopback');

module.exports = function(Thing) {

// HOW TO USE FOR TESTING
//
// at http://127.0.0.1:3000/explorer/#!/things/create
// create a thing {"color":"red"}
//
// then at http://127.0.0.1:3000/explorer/#!/things/prototype_paint
// enter id 1 and try it out
//
// watch the server console log

function beforeRemotePaint(remoteHookContext, unused, next) {
var loopbackContext = loopback.getCurrentContext();
loopbackContext.thingInstance = remoteHookContext.instance;
console.log("the color before is", loopbackContext.thingInstance.color);
//
Promise.resolve()
.then(function() {
return true;
})
.then(function() {
console.log("about to call next() from before remote method");
next();
Expand Down

0 comments on commit 5349520

Please sign in to comment.