Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fiber for async code #307

Open
totty90 opened this issue Feb 13, 2015 · 7 comments
Open

Use fiber for async code #307

totty90 opened this issue Feb 13, 2015 · 7 comments

Comments

@totty90
Copy link

totty90 commented Feb 13, 2015

No description provided.

@samccone
Copy link
Contributor

@totty90 mind expanding on this?

@totty90
Copy link
Author

totty90 commented Feb 13, 2015

By using fibers your code can look like this

var a = makeAsyncRequest().wait();
var b = usingAVarInAnotherAsyncRequest(a).wait();
expect(b).to.be(4);

While with the current way of doing things is kind a pain.

@samccone
Copy link
Contributor

Hi @totty90 , thanks for the great idea. If you are interested in taking a stab at implementing this I would love to take a look and we can evaluate further. You are correct that using the pattern above would remove quite a bit of complexity when writing tests.

Luckily we have a pretty extensive set of unit and integration tests for this library so you can quite easily make a pass on this and be able to see if it is going to be possible.

Thanks again.

@totty90
Copy link
Author

totty90 commented Feb 13, 2015

You are welcome, I've just moved all my server side services to fibers and 100 lines of code with async just transformed in 10 readable lines. Is like magic. No problems to debug yet.
I'm looking into testing frameworks, so I can't promise to make a pull here.

@samccone
Copy link
Contributor

ok @totty90 well if you are interested, we are very open to improvements.
Thanks again for bringing this up.

@DominikGuzei
Copy link

This is pretty much the same problem that I had to solve with integrating Meteor with pioneer.js
The short answer is: it is not "really" possible because fibers and promises are orthogonal concepts. But you can introduce a function on the world that wraps a callback inside a fiber.

You can see how I did it with space-pioneer, an acceptance testing framework for Meteor.js based on pioneer.js

@totty90
Copy link
Author

totty90 commented Mar 26, 2015

Here it is cucumber + fibers + more goodies: https://github.com/hackhat/cucumberry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants