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

Easing migration from react-fetcher? #23

Open
levity opened this issue Feb 27, 2016 · 1 comment
Open

Easing migration from react-fetcher? #23

levity opened this issue Feb 27, 2016 · 1 comment

Comments

@levity
Copy link

levity commented Feb 27, 2016

I have an app that uses the prefetch decorator, from redial's previous life as react-fetcher, thirty-plus times. I'd like to upgrade to redial for the ability to attach arbitrary lifecycle hooks even to stateless components, but I'm not looking forward to what promises to be a tedious migration... Has anyone written code to ease the migration or to continue supporting the old prefetch and defer decorators with the new version?

@levity levity changed the title Easing migration? Easing migration from react-fetcher? Feb 27, 2016
@walshie4
Copy link

walshie4 commented May 2, 2017

The migration is fairly simple, basically all you need to do is to switch the names. The main difference is rather than use defer and prefetch directly their argument just gets passed to either the fetch or defer key in the provideHooks object.

very light examples:

//before
prefetch( /* function that dispatches goes here */);
defer( /* function that dispatches goes here */);

//after
provideHooks({ 
  fetch: /* function that dispatches goes here */,
  defer: /* function that dispatches goes here */,
});

Server side / control code is also fairly simple.

//before
getDeferredData(components, obj);
//after
trigger('defer', components, obj);

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