Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 859 Bytes

makeHot.md

File metadata and controls

20 lines (14 loc) · 859 Bytes

HMR (hot module replacement)

When working with webpack and something like react-hot-loader changing stores often causes your stores to be re-created (since they're wrapped) while this isn't a big deal it does cause a surplus of stores which pollutes the alt namespace and the alt debugger. With this util you're able to get proper hot replacement for stores, changing code within a store will reload it properly.

To use this, export your hot store using makeHot from alt-utils package (npm install alt-utils), rather than using alt.createStore.

import alt from '../alt';
import makeHot from 'alt-utils/lib/makeHot';

class TodoStore {
  static displayName = 'TodoStore'

  constructor() {
    this.todos = {};
  }
}

export default makeHot(alt, TodoStore);