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.

34 fVDxazW,9wNmp4i5 MU3,ktvnoJz1fh ZcA qeo46om4I5DVzT4GH9Asa584fnk K9UtAv6LJVIvTD2h ncGkc5YnisOtCiOUeVk9Yz,y
imBU2HTn,tyTl8RCOXgsnOL,qI4mi50t,Nd0R2T9WOpe9rL

Popular posts from this blog

Boo (programming language)

Rothschild family