# ember-monitorable

> Ember Mixin for monitoring changes to objects.

Latest version **0.7.8** (published 2015-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-monitorable
pnpm add ember-monitorable
yarn add ember-monitorable
bun add ember-monitorable
```

## 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.7.8 |
| Published | 2015-09-04 |
| First published | 2015-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eric Webster |
| Maintainers | quantumking |
| Keywords | ember monitor, ember observe, ember changes |

## Links

- npm: https://www.npmjs.com/package/ember-monitorable
- Repository: https://github.com/QuantumKing/EmberMonitorable
- Homepage: https://github.com/QuantumKing/EmberMonitorable#readme
- Issues: https://github.com/QuantumKing/EmberMonitorable/issues
- npm.io page: https://npm.io/package/ember-monitorable

## Recent versions

- 0.7.8 (latest) — 2015-09-04
- 0.7.7 — 2015-08-22
- 0.7.6 — 2015-08-21
- 0.7.5 — 2015-06-01
- 0.7.4 — 2015-06-01
- 0.7.3 — 2015-06-01
- 0.7.2 — 2015-02-18
- 0.7.1 — 2015-02-17
- 0.7.0 — 2015-02-16

## README

# EmberMonitorable
Ember Mixin for monitoring changes to objects.

# Install

<a href="https://nodei.co/npm/ember-monitorable/"><img src="https://nodei.co/npm/ember-monitorable.png"></a>

Install via `npm` or simply download this repository and include `ember-monitorable.js` in your project.

# Usage

The Ember.Monitorable mixin adds the property `hasChanges` to an object.
Extend any object with the Ember.Monitorable mixin and include the property `monitoredObservables`:

```js
var Book = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['title']
})
  ```
Now, when the Book object's title property changes, `Book.get('hasChanges')` will be `true`, and `false` when those changes are undone.

It is also possible to monitor properties of each element in an array:

```js
var Book = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['publishers.@each.name']
})
  ```

In fact, anything which can be observed using Ember's `addObserver` can be monitored using the `monitoredObservables` property.

### Relationships

If another object has the Monitorable mixin included, then its possible to monitor it, or an array of such objects, as a relationship through the `monitoredRelationships` property:
```js
var Author = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['name']
})
```

```js
var Publisher = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['name']
})
```

```js
var Book = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['title'],
  monitoredRelationships: ['author', 'publishers']
})
```

#### Identifiers

Sometimes its necessary to differentiate between objects in a relationship by an identifier instead of the objects themselves. To do this, include the option `id` with the property used as the identifier:

```js
var Book = Ember.Object.extend(Ember.Monitorable, {
  monitoredObservables: ['title'],
  monitoredRelationships: ['author', { publishers: { id: '_id' } }]
})
```

### Reset monitoring

To reset monitoring to include all current changes, call `Book.commit()`.

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