This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@grebaldi/component-factory

2.0.0 • Public • Published

component-factory

create universal, stateful components

Installation

npm:

npm install --save @grebaldi/component-factory

yarn:

yarn add @grebaldi/component-factory

Usage

<div id="my-label"></div>
<button id="my-button"></button>
import create from '@grebaldi/component-factory';

create((update, reconcile) => {
	const button = document.getElementById('#my-button');
	const label = document.getElementById('#my-label');

	button.addEventListener('click', () => update(
		state => ({
			...state,
			counter: state.counter + 1
		})
	));

	return reconcile({counter: 0}, (oldState, newState) => {
		if (oldState.counter !== newState.counter) {
			label.innerHTML = `Counter: ${newState.counter}`;
		}
	});
});

License

MIT, see LICENSE.md

Readme

Keywords

none

Package Sidebar

Install

npm i @grebaldi/component-factory

Weekly Downloads

5

Version

2.0.0

License

MIT

Last publish

Collaborators

  • _grebaldi