Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lmettini/data-obs
Simple javascript data observer
https://github.com/lmettini/data-obs
Last synced: 4 months ago
JSON representation
Simple javascript data observer
- Host: GitHub
- URL: https://github.com/lmettini/data-obs
- Owner: lmettini
- License: mit
- Created: 2013-11-26T21:49:09.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-30T11:09:21.000Z (over 7 years ago)
- Last Synced: 2024-08-01T13:34:10.547Z (7 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# data-obs
Lightweigh data observer, no need to load heavy libraries. Just store your data and add some triggers when this data change. If you want to see it working, here is a [dummy demo](http://lmettini.github.io/data-obs-demo/)## how it works
You set or observe data using a same data-id, that's the way the triggers are linked to the data
### set data interface
The data-id is an unique string/interger that will be use to observe any change in the future of the data stored in the dataObs, the data could be any type of Object
```javascript
dataObs.set('data-id' ,data);
```
### observe interface
To observe the changes of a data-id you need to create a function that will recieve one parameter, that function is the trigger that is executed every time the data change. When a trigger is set to observer is going to be executed in the case when some data already stored with the same data-id.
```javascript
dataObs.observe('data-id' ,function(data){
// do your stuff here ;)
});
```
### get data interface
Also you can check the value that a data-id have assigned
```javascript
dataObs.get('data-id');
```
# LicenseMIT