嗨,我正在使用nld包
当promise处于待实现状态之前,它会在实现或拒绝状态之前被调用
在我的abc方法中,我正在调用另一个诺言,等待它解决,然后解决此问题
// In page service.js
module.exports.abc = (a, b) => {
return new Promise((resolve, reject) => {
// This calls a a promise in an other page
var xyz = xyzDao.getValues();
xyz.then((response) => {
console.log("beforeResolve");
resolve(response);
console.log("beforeResolve");
})
})
}
//In Page MeldService.js
var meld = require('meld');
var service = require('service')
let advice = {
before: function() {
let joinPointObj = meld.joinpoint()
console.log("In Before of ",joinPointObj.method)
},
afterReturning: function(returningValue){
let joinPointObj = meld.joinpoint()
console.log("In After Returning of ", joinPointObj.method);
console.log(returningValue);
}
}
meld(service, ['abc'], advice);
在我的日志中 -在abc之前 -在abc返回之后 - 诺言 { } -解决之前,解决之后
谢谢