Skip to content
Utilities for running a redux-bundler app inside a worker
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
package-lock.json
package.json

README.md

redux-bundler-worker

Utilities for running a redux-bundler app inside a worker. Largely for demonstration purposes, I have not shipped any production apps built this way.

But it demonstrates a rather feature-complete mechanism for doing so. Utilizing a worker for the entire redux application and then simply doing rendering in the main thread.

install

npm install redux-bundler-worker

example

In the main thread:

import { render, h } from 'preact'
import { Provider } from 'redux-bundler-preact'
import RootComponent from './components/root'
import { getStoreProxy } from 'redux-bundler-worker'

// init our worker
const worker = new Worker('/build/worker.js')
// pass the worker into getStoreProxy to
// get something that mimics the API of a
// redux store created by redux-bundler
const storeProxy = getStoreProxy(worker)

// render our root component passing the proxy
// as if it were the store to Provider:
render(
  <Provider store={storeProxy}>
    <RootComponent />
  </Provider>,
  document.getElementById('app')
)

In the worker:

import getStore from './src/bundles'
import { setUpWorker } from 'redux-bundler-worker'

// setUpWorker expects a function it can call *with* initial
// data that will return our redux store. This is what is returned
// by calling redux-bundle's `composeBundles` function anyway.
setUpWorker(getStore)

change log

  • 0.0.3 - now handling scroll position restoration
  • 0.0.2 - initial public release

credits

If you like this follow @HenrikJoreteg on twitter.

license

MIT

You can’t perform that action at this time.