Skip to content

Instantly share code, notes, and snippets.

View ponkys's full-sized avatar
🦦

Diego M Mosquera ponkys

🦦
View GitHub Profile
@ponkys
ponkys / counter-composition.js
Created January 15, 2019 10:47 — forked from adrianmcli/counter-composition.js
An example of using plain functions and composing them to make state containers.
// state container definition
const useState = initVal => {
let val = initVal;
const get = () => val;
const set = x => (val = x);
return Object.freeze({ get, set });
};