npm.io
1.0.11 • Published 8 years ago

ely

Licence
Unlicense
Version
1.0.11
Deps
1
Vulns
0
Weekly
0
Stars
1

ely npm version Build Status Coverage Status devDependencies Status

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';
More examples

Check the examples

Documentation

Check the documentation

What is next

Check the todo

What have changed

Check the changelog

Keywords