i'm trying create job, reuses modules express app relies on node-harmony. (and works nicely), don't know how use generators @ "top-level".
so have file job.js
var locator = require('./../locatorsetup'); yield locator.connect(); // returns promise console.log('connected'); which start calling
node --harmony job.js unfortunately get:
yield locator.connect(); ^^^^^^^ syntaxerror: unexpected identifier what's recommend way of doing this?
p.s. i'm using bluebird promise library..
you can't. yield can used within generator function.
consider using co execute generator functions @ top level, so:
co(function *() { yield locator.connect(); }); co returns promise can use track completion of passed generator function.
Comments
Post a Comment