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

Allow refreshing. #345

Open
conartist6 opened this issue Mar 18, 2019 · 3 comments
Open

Allow refreshing. #345

conartist6 opened this issue Mar 18, 2019 · 3 comments

Comments

@conartist6
Copy link

There should be a simple API for refreshing the current route's data, which is to say re-triggering its thunk. This is a useful bit of functionality to be able to expose directly to users, e.g. by having a button somewhere in your site's layout that will reload data for whatever page is active. It is also important to be able to do programmatically, for example when some update is known to have caused the page's data to become stale.

@faceyspacey
Copy link
Owner

i like that feature idea.

@hedgepigdaniel
Copy link
Contributor

hedgepigdaniel commented Mar 19, 2019

I think it would be fairly simple to do with the existing API - assuming you have redux-thunk set up:

const refreshCurrentRoute = (dispatch, getState) => {
  const currentLocation = {
    type: getState().location.type,
    payload: getState().location.payload,
    // ...etc
    // maybe if you do something to avoid unecessary data loading you also need a flag to ensure that the refresh actually happens
  };
  dispatch(redirect(currentLocation));
};

Then if you want to refresh the route data, you can dispatch(refreshCurrentRoute)

@ScriptedAlchemy
Copy link
Collaborator

Agreed, this is an effective way to do it with the existing API, it would be nice to abstract it into the core though

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

4 participants