# core-listener

> javascript class helps track changes in array and object

Latest version **0.1.0** (published 2016-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install core-listener
pnpm add core-listener
yarn add core-listener
bun add core-listener
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-08-25 |
| First published | 2016-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Max Ulyanov |
| Maintainers | web.ulyanov |

## Links

- npm: https://www.npmjs.com/package/core-listener
- Repository: https://github.com/M-Ulyanov/CoreListener
- Homepage: https://github.com/M-Ulyanov/CoreListener#readme
- Issues: https://github.com/M-Ulyanov/CoreListener/issues
- npm.io page: https://npm.io/package/core-listener

## Recent versions

- 0.1.0 (latest) — 2016-08-25

## README

# CoreListener

javascript class helps track changes in array and object


## Create instance
```html
  var listener = new CoreListener();
```

## For array
```html
 var array = [1, 2, 3];
  listener.add({
    entity: array,
    callback: function (args) {
      console.log('method:' + args.method); // called method to change the array
      console.info(args.previousValue); // previos value of the array
      console.warn(args.value); // current value of the array
    }
  });

  array.push(4); // called callback
  array.splice(5, 0, 'wow'); // called callback

  listener.remove({
    entity: array
  });
  array.pop(); // NOT called callback

  console.log(array); // [1, 2, 3, 4]
```
 
## For object
```html
  var user = {
      name: 'John',
      age: 25
    }
  
    listener.add({
        entity: user,
        properties: ['name', 'age'],
        callback: function(args) {
          console.log('props:' + args.prop); // changed property
          console.info(args.previousValue); // previos value of the object
          console.warn(args.value); // current value of the object
        }
      });
  
    user.age = 30; // called callback
  
    listener.remove({
      entity: user,
      properties: 'age'
    });
  
    user.age = 32 // NOT called callback
    user.name = 'Jordan' // called callback
```

##Browser Support
All modern browsers and IE9+

---
_Source: https://npm.io/package/core-listener · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
