node-fibers : yielding data out of a Fiber

Multi tool use
Multi tool use


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 instead of fibers . npmjs.com/package/sync
– Ratan Uday Kumar
Jul 2 at 4:04









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

n7oQ79jlKAf1ouL6C0RtxLfXB,q3UEDwf NVpdOYGAaQujD1,KrnX gT UECzLjQ4PQX6iuhjGHPvL
HCcb2FqEK6bbFC 5rVCt1oqDEOA

Popular posts from this blog

Rothschild family

Cinema of Italy