jmar777 / suspend

Callback-free control flow for Node using ES6 generators.
547 stars 22 forks source link

Generators cannot be resumed once completed. #31

Closed polizinha closed 7 years ago

polizinha commented 8 years ago

Hello, I'm using suspend.resume() to receive node cb style, but I'm obtain "Generators cannot be resumed once completed." error. Can u help me?

suspend(function* () { var available = Modulus.checkModulus(company, 'advanced_config', suspend.resume()); if (available) { console.log('YEY');} })();

In another file: var checkModulus = function (company, modulus, callback) { return callback(null, true); };

Thanks in advance!

jmar777 commented 8 years ago

It's throwing up that error because you're calling suspend.resume() without having yielded.

Try replacing this line:

var available = Modulus.checkModulus(company, 'advanced_config', suspend.resume());

...with this:

var available = yield Modulus.checkModulus(company, 'advanced_config', suspend.resume());.

polizinha commented 8 years ago

Oh... Shame on me =/ It works! Thanks!

noorkaximi commented 7 years ago

if your problem is solved kindly close the ticket

jmar777 commented 7 years ago

Closing this issue, as it seems that it's been resolved since March. :)