1.0.8 • Published 8 days ago

@orago/variable-observer v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
8 days ago

@orago/variable-observer

Usage:

new VariableObserver(<startingValue>);
import VariableObserver from '@orago/variable-observer';

const test = new VariableObserver('friday');

Creating a listener

function myCallback (value){
	console.log('hello world, today is', value);
}

test.subscribe(myCallback);

Updating values

test.value = 'saturday';
/* console => */ 'hello world, today is saturday'

Removing a listener

test.unsubscribe(myCallback);

Handling minor changes in an object

By default, this util will not handle changes within an object

you will have to do this yourself

const me = new VariableObserver({
	name: 'orago',
	age: 17
});

me.value.name = 'gato';
// Nothing happens since value wasn't modified directly

// to manually call all subscribed events use
me.notify();
1.0.8

8 days ago

1.0.7

8 days ago

1.0.6

8 days ago

1.0.5

8 days ago

1.0.4

8 days ago

1.0.3

5 months ago

1.0.0

9 months ago