hadrienl / observe

A very simple way to observe data changes in javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage

import {State} from 'state';

const state = new State();

const off = state.observe('foo', (newVal, oldVal) => console.log(newVal, oldVal));

state.foo = 'bar'; // console => 'bar' undefined
state.foo = 'babar'; // console => 'babar' 'bar'

off();

state.foo = 'foo'; // nothing

About

A very simple way to observe data changes in javascript


Languages

Language:JavaScript 100.0%