1.1.4 • Published 6 years ago

hyperapp-webpack-hmr v1.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

hyperapp-webpack-hmr

DEPRECATED Readme now contains example usage of hyperapp with webpack-hmr, this package is no longer needed

Example Usage

  1. Setup webpack for hmr as specified in their documentation.

  2. Basically you need to make it so your whole app will be re-instantiated on top of your currently rendered output which will use the built-in hydration. The only requirement of your app is you provide a getState() action that returns the current state for access in our module.hot code.

/* myApp.js */
var { h, app } = require('hyperapp')
module.exports = function myApp(initState) {
  return app(
    initState,
    {
      getState: () => state => state,
      increment: () => state => ({ count: state.count + 1 }),
      decrement: () => state => ({ count: state.count - 1})
    },
    (state) => h("div", {}, count)
  );
}

To complete the hmr setup your entry point should have something like the following.

/* index.js */
var myApp = require('./myApp')

var appActions = myApp({ count: 0 })

if (module.hot) {
  module.hot.accept('./myApp', function(){
    appActions = myApp(appActions.getState())
  })
}
1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago