Skip to content

Instantly share code, notes, and snippets.

View rajeshdavidbabu's full-sized avatar
🎯
Coding and other things !

Rajesh Babu rajeshdavidbabu

🎯
Coding and other things !
View GitHub Profile
@adrianmcli
adrianmcli / counter-composition.js
Last active February 5, 2019 13:23
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 });
};