redux-bundler-worker
Utilities for running a redux-bundler app inside a worker
Last updated 3 years ago by henrikjoreteg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install redux-bundler-worker 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.3                                ...           latest (3 years ago)

3 Versions

  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |