Created
May 11, 2015 11:53
-
-
Save briancavalier/d1f7ca7b4326be8c1ab0 to your computer and use it in GitHub Desktop.
Wire issue 173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var when = require('when'); | |
var wire = require('../../wire'); | |
require('when/monitor/console'); | |
var logger = console; | |
var contextDefinition = { | |
$plugins: [ | |
//{ module: '../../debug' }, | |
{ module: '../../aop' } | |
], | |
logger: { | |
before: function () { | |
logger.info('Before returning a promise', arguments) | |
}, | |
afterFulfill: function () { | |
logger.info('Sucessfully fulfilled promise', arguments) | |
}, | |
afterReject: function (err) { | |
logger.error('Failed to fulfill promise', err.stack || err) | |
} | |
}, | |
myInst: { | |
create: { | |
test: function () { | |
return when.reject(new Error('Test rejecting')) | |
} | |
}, | |
before: { | |
test: 'logger.before' | |
}, | |
afterFulfilling: { | |
test: 'logger.afterFulfill' | |
}, | |
afterRejecting: { | |
test: 'logger.afterReject' | |
} | |
} | |
}; | |
wire(contextDefinition, { require: require }) | |
.then(function (ctx) { | |
console.log('here'); | |
ctx.myInst.test() | |
.then(function (r) { | |
console.log('ok'); | |
}) | |
.catch(function (e) { | |
console.log('err'); | |
}) | |
.done(); | |
}) | |
.catch(function (e) { | |
logger.error('Error initializing app', e.stack || e) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> nvm current | |
iojs-v2.0.0 | |
> node ./experiments/issue-173/test.js | |
here | |
Before returning a promise {} | |
Failed to fulfill promise Error: Test rejecting | |
at Object.contextDefinition.myInst.create.test (/Users/brian/Projects/cujojs/wire/experiments/issue-173/test.js:28:24) | |
at callOrig (/Users/brian/Projects/cujojs/wire/node_modules/meld/meld.js:111:18) | |
at callOrigAndOn (/Users/brian/Projects/cujojs/wire/node_modules/meld/meld.js:154:18) | |
at callNext (/Users/brian/Projects/cujojs/wire/node_modules/meld/meld.js:220:8) | |
at Object.Advisor._callAroundAdvice (/Users/brian/Projects/cujojs/wire/node_modules/meld/meld.js:290:11) | |
at Object.Advisor.advised.advised [as test] (/Users/brian/Projects/cujojs/wire/node_modules/meld/meld.js:130:33) | |
at /Users/brian/Projects/cujojs/wire/experiments/issue-173/test.js:46:14 | |
at tryCatchReject (/Users/brian/Projects/cujojs/wire/node_modules/when/lib/makePromise.js:845:30) | |
at runContinuation1 (/Users/brian/Projects/cujojs/wire/node_modules/when/lib/makePromise.js:804:4) | |
at Fulfilled.when (/Users/brian/Projects/cujojs/wire/node_modules/when/lib/makePromise.js:592:4) | |
err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment