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

Hot Reload Saga Support #391

Closed
GantMan opened this issue Sep 27, 2016 · 4 comments
Closed

Hot Reload Saga Support #391

GantMan opened this issue Sep 27, 2016 · 4 comments

Comments

@GantMan
Copy link
Member

GantMan commented Sep 27, 2016

As mentioned in the hot-reloading ticket, we should have support at the Provider level, so sagas and redux can be hot-reloaded. To be done by whomever gets there first!

Visual part was done at #155

References:
https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/redux/create.js#L28-L32

http://stackoverflow.com/questions/34243684/make-redux-reducers-and-other-non-components-hot-loadable

@GantMan
Copy link
Member Author

GantMan commented Oct 7, 2016

I took a quick stab at this and it failed. Here's my code that I was playing with in CreateStore.js:

  console.log('HOT', module.hot)
  // hot-reload Redux store
  if (__DEV__ && module.hot) {
    module.hot.accept(['./', './TemperatureRedux', './LoginRedux'], () => {
      const nextRootReducer = combineReducers({
        temperature: require('./TemperatureRedux').reducer,
        login: require('./LoginRedux').reducer
      })
      store.replaceReducer(nextRootReducer)
    })
  }

Noticed hot module replacement always works after the first error message is displayed.

Bonus docs: https://webpack.github.io/docs/hot-module-replacement.html

@GantMan
Copy link
Member Author

GantMan commented Oct 7, 2016

now that I know editing a saga file twice makes hot-reloading work... I'm less inclined to figure this out, lol. No clue on how that works.

@wafisher
Copy link

Are there any updates on this? I just want to confirm that with the current version, there's no way to Hot Reload any saga code, correct? Unfortunately, that saving-it-twice trick doesn't seem to work for me.

@skellock
Copy link
Contributor

Hot reloading sagas is app-dependant. Sagas maintain their state and interrupting them may or may not make sense for all apps. Have a look at task cancellation in sagas for more details.

Reducers on the other hand can be reloaded!

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

3 participants