1.0.0-alpha.2 • Published 6 years ago

@transclusion/runtime-browser v1.0.0-alpha.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

@transclusion/runtime-browser

Usage

import {run} from '@transclusion/runtime-browser'

run(
  {
    element: document.getElementById('root'),
    props: {},
    worker: new Worker('worker.js')
  },
  context => {
    context.ports.history.subscribe(msg => {
      switch (msg.type) {
        case 'PUSH_STATE':
          history.pushState(msg.state, msg.title, msg.path)
          break

        case 'REPLACE_STATE':
          history.replaceState(msg.state, msg.title, msg.path)
          break
      }
    })

    window.addEventListener('popstate', event => {
      context.ports.history.send({
        type: 'POP_STATE',
        state: event.state,
        path: location.pathname
      })
    })
  }
)
1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago