Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yakovkhalinsky/overlord

Utility for watching changes in collections
https://github.com/yakovkhalinsky/overlord

Last synced: 1 day ago
JSON representation

Utility for watching changes in collections

Awesome Lists containing this project

README

        

**OVERVIEW**

Overlord was designed as a utility to help manage aggregate watches in Angular.

As it just compares collections of values or objects, it could in theory be used for monitoring changes on generic collections.

Overlord provides a couple of options in regards to managing callbacks on changes.

**DEPENDENCIES**

Overlord depends on having either the lodash or underscore library to do equality checking.

lodash website:
underscore website:

**USAGE**

*Creating an overlord before adding your watchers*

var overlord = new ninebytes.Overlord();

*Adding a basic watcher basic*

overlord.addWatcher('watchedProperty');

*Adding a watcher with a callback*

Don't execute the callback when the WATCHER function is called.

overlord.addWatcher('watchedProperty', cb);

Execute the callback when the WATCHER function is called.

overlord.addWatcher('watchedProperty', cb, true);

*Get the watch expression for an Angular watch*

overlord.getWatchExpression()

Returns a valid Angular watch expression, e.g. ['foo', 'bar', 'boo'].

*Calling the watcher*

overlord.WATCHER(newValues, oldValues);

newValues and oldValues will be a collection of values corresponding to the named watchProperty.

**CHANGES**

Calling overlord.WATCHER(newValues, oldValues); returns a changes object.

{

watchedProperty: {
source: 'watchedProperty',
newVal: 'newValue',
oldVal: 'oldValue',
cb: callbackFunction
}
}

**NOTE:** If a watch is added without setting the execute flag on the callback, e.g. by setting the callback like this: overlord.addWatcher('watchedProperty', cb);, the cb property will be set to ```undefined```.

**EXAMPLES**

A working set of examples can be found in the ```/example``` directory.

**TO DO**
- Add unit tests
- Better documentation

**CONTRIBUTION**

Contributions are more than welcome!

Please fork and add pull requests, or add issues if you feel something is missing.

**LICENSE**

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see .