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

Why callback handlers? #4

Open
ryyppy opened this issue Oct 21, 2016 · 1 comment
Open

Why callback handlers? #4

ryyppy opened this issue Oct 21, 2016 · 1 comment

Comments

@ryyppy
Copy link

ryyppy commented Oct 21, 2016

Hey it's me again!
I am just leaving some issues while I am discovering the API and will ask questions which will pop in my head, so everything is in structure ... I have used co and redux-saga quite a lot and was a little bit confused by some things :-)

So here is the most important one... Why does runtime always need two callbacks? Why doesn't it also support Promises?

like this:

const runtime = create();

const successFn = () => {};
const failFn = () => {};

runtime(myGenerator).then(successFn).catch(failFn);

(I am currently working on a pull request to make examples easier to understand btw)

@youknowriad
Copy link
Owner

Hey! I'm happy to get all this feedback :)

So, about the callback choice instead of promises. Basically, it's a choice due to synchronization errors we could have with promises. More background on this here redux-saga/redux-saga#16 (comment)

And here is an example of a bug that can be caused by a Promise based implementation redux-saga/redux-saga#50

And since I'm using rungen with redux (see redux-rungen), I chose to use callbacks to avoid these synchronization errors (Hard problem to solve).

I've not followed the redux-saga work lately, but I think they managed to get rid of the synchronization issues and still use promises. So, I may be open to using only promises if we can make sure those issues are fixed.

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

No branches or pull requests

2 participants