Code Monkey home page Code Monkey logo

purescript-halogen-hmr-example's Introduction

purescript-halogen HMR Example

demo

How to

  1. copy src/Halogen.Component.patch.js to your codebase
  2. change webpack.config.js to point Halogen.Component/index.js to the patched version
  alias: {
    "../Halogen.Component/index.js": "Halogen.Component.patch.js"
  }
  1. setup hmr in your entry script
if (module.hot) {
  module.hot.accept("Main", function() {
    document.body.innerHTML = "";
    require("Main").main();
  });
}

NOTE: only tested with purescript-halogen master.

purescript-halogen-hmr-example's People

Contributors

rnons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

purescript-halogen-hmr-example's Issues

shouldnt we call dispose method on reload?

here

document.body.innerHTML = "";

import Main from "Main";
import "./Storybook.css";

if (process.env.NODE_ENV !== "production") {
  require("Main").main();

  if (module.hot) {
    module.hot.accept("Main", function() {
      document.body.innerHTML = "";
      require("Main").main();
    });
  }
}

should be written as

import Main from "Main";
import "./Storybook.css";

if (process.env.NODE_ENV !== "production") {
  let disposeFn = require("Main").main()

  if (module.hot) {
    module.hot.accept("Main", function() {
      disposeFn();
      document.body.innerHTML = "";
      disposeFn = require("Main").main();
    });
  }
}

of course main should return Effect (Effect Unit)

https://github.com/nonbili/purescript-halogen-hmr-example/blob/master/src/Main.purs#L22

https://github.com/purescript-halogen/purescript-halogen/blob/337d450fdd5e18de6f75920f808c34a173ff8d88/src/Halogen.purs#L35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.