How to use the webpack-hot-middleware/client.subscribe function in webpack-hot-middleware

To help you get started, we’ve selected a few webpack-hot-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wochap / webpack-boilerplate / build / webpack / client.js View on Github external
// imported only in development

const hotClient = require('webpack-hot-middleware/client')
hotClient.subscribe(function (event) {
  if (event.action === 'reload') {
    // force page reload when html-webpack-plugin template changes
    window.location.reload()
  }
})
github Copyes / webpack-project-seed / build / dev-client.js View on Github external
var hotClient = require('webpack-hot-middleware/client')

// 订阅事件,当 event.action === 'reload' 时执行页面刷新
hotClient.subscribe(function (event) {
    if (event.action === 'reload') {
        window.location.reload()
    }
})
github saberland / saber / packages / saber / vue-app / dev-client.js View on Github external
export const init = ({ router }) => {
  window.__SABER_DEV_CLIENT_ID__ = Math.random()
    .toString(36)
    .substring(7)

  client.subscribe(obj => {
    if (obj.action === 'router:push' && obj.id === __SABER_DEV_CLIENT_ID__) {
      if (obj.hasError) {
        console.error(`You need to refresh the page when the error is fixed!`)
      }

      if (obj.alreadyBuilt) {
        router.push(obj.route)
      } else {
        const handler = status => {
          if (status === 'idle') {
            module.hot.removeStatusHandler(handler)
            router.push(obj.route)
          }
        }

        module.hot.addStatusHandler(handler)