Posts

Showing posts with the label node-fibers

node-fibers : yielding data out of a Fiber

node-fibers : yielding data out of a Fiber I just started working with node-fibers to actually try out something I had in mind to make it easier to make mongoose queries a little more easy to deal with. Unfortunately , I don't seem to understand what I'm doing wrong to get the users returned using the yield() to the main function that called Fiber. users yield() var Fiber = require("fibers"); var mongoose = require("mongoose"); var User = require('./user'); mongoose.connect('mongodb://localhost/fibers'); function wrapper() { let f = Fiber(function(){ var results; var fiber = Fiber.current; User.find({},function(err,users){ var results = Fiber(function(){ fiber.run(users); }).run(); }) results = Fiber.yield(); Fiber.yield(results); }); return f.run.bind(f); } var result = wrapper()(); console.log(result); use sync in...