Skip to content

Instantly share code, notes, and snippets.

View keenwon's full-sized avatar
😆
lol

Keenwon keenwon

😆
lol
View GitHub Profile
@keenwon
keenwon / unistore.js
Created November 22, 2017 02:05 — forked from developit/unistore.js
dead simple centralized state container ("store"), with preact bindings.
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/