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 is there a need for a double-callback? #8

Closed
smirea opened this issue Jan 10, 2017 · 2 comments
Closed

Why is there a need for a double-callback? #8

smirea opened this issue Jan 10, 2017 · 2 comments

Comments

@smirea
Copy link
Collaborator

smirea commented Jan 10, 2017

Throughout the readme the following pattern keeps popping up:

@withJob(() => () => fetch(...))
class Foo {}

and the docs themselves clearly state

// Provide a function that will create a "work" function.

But checking the behavior and the code: https://github.com/ctrlplusb/react-jobs/blob/master/src/withJob.js#L64

I don't get how that is supposed to function. work() gets called and the props are passed to the top most method and, using the recommended syntax, the inner function gets returned as a result.

It seems intuitive to me that the format should simply be

@withJob(props => Promise.resolve())
class Foo {}

Edit: just using the above intuitive syntax actually works as expected

@ctrlplusb
Copy link
Owner

Ummm.... I think this may be a complete mess up on the docs! I'll have a look thanks!

@ctrlplusb
Copy link
Owner

OMG, that was embarrassing. I don't know why I wrote it out like that. Parts of the README had it right and others not. Thank you for that!

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