wildpeaks / 2018-package-preact-render-worker

[ARCHIVED] Renders a Preact component in the DOM, and listens to a Web Worker for the props.

Home Page:https://www.npmjs.com/package/@wildpeaks/preact-render-worker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render to DOM, using a Web Worker

Greenkeeper badge

Renders a Preact component in the DOM, and listens to a Web Worker for the props (similar to @wildpeaks/react-render-worker).

Install:

npm install @wildpeaks/preact-render-worker

Example:

import {h, Component} from 'preact';
import {render} from '@wildpeaks/preact-render-worker';

interface MyProps {
	href: string;
}
interface MyState {
	example: boolean;
}
class MyComponent extends Component<MyProps, MyState> {
	render(props: MyProps) {
		return h('a', props);
	}
}

let throws = false;
const container = document.createElement('div');

// This will render the computer in container everytime the Web Worker emits nes props.
render<MyProps>(container, MyComponent, 'myworker.js');

// Forwards a message to the Web Worker to trigger a change in the Web Worker.
window.dispatch({action: 'example'});

About

[ARCHIVED] Renders a Preact component in the DOM, and listens to a Web Worker for the props.

https://www.npmjs.com/package/@wildpeaks/preact-render-worker

License:MIT License


Languages

Language:TypeScript 96.8%Language:JavaScript 3.2%