So I am trying to use co
to wrap around MongoDB methods that return promises
eg
http://mongodb.github.io/node-mongodb-native/2.0/reference/ecmascript6/crud/
I see co
being used like:
co(function*() {
which seems like an anonymous function. Fine in the main body of your code, but is there a way to get at the values yielded inside?
eg to basically get at the results of the co
routine:
If I could do:
let wrap = co(function* (collName) {
let res = yield collection.findOne({});
yield res;
});
and then elsewhere
let res = wrap("Topics");
but I get
TypeError: wrap is not a function
Tried also:
co(function* wrap(collName) {
...
co.call(this, wrap("Topics"));
let wrap = co.wrap(function* (collName) { ...
but still no luck.