ely
v1.0.11
Published
Emit Light and Yell
Downloads
5
Readme
ely
ely - Emit Light and Yell
Make any object parameters emittable
Make listening for changes easier with automatic property change emitter.
Install:
Install with npm
npm install ely
Use standalone
<script src="https://cdn.jsdelivr.net/npm/ely/standalone/ely.js"></script>
or
<script src="https://cdn.jsdelivr.net/npm/ely/standalone/ely.min.js"></script>
Access the library:
Import
import { ely } from 'ely';
Require
const ely = require('ely');
Standalone
<script src="https://cdn.jsdelivr.net/npm/ely/standalone/ely.min.js"></script>
<script>
// global ely variable exists
</script>
Basics:
ely static
Ely library provides a static library to map and unmap objects. Map returns emitter with signals named as every property that can be monitored. Also you have '*' to monitor all changes within a single place.
import { ely } from 'ely';
const object = {
a: 'value of a',
b: 'value of b'
};
const emitter = ely.map(object);
emitter.on('a', (_new, _old) => {
console.log(_new, _old);
});
emitter.on('*', (_new, _old, key) => {
console.log(_new, _old, key);
});
object.a = 'new value of a';
object.b = 'new value of b';