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

https://github.com/muke1908/observableobj

Observe a javascript object and react when property changes.
https://github.com/muke1908/observableobj

Last synced: about 1 year ago
JSON representation

Observe a javascript object and react when property changes.

Awesome Lists containing this project

README

          

# Observable Object
Observe a javascript object and react when property changes.

## Install
`npm install reactiveobj`

## Usage

```
import Observable from 'reactiveobj';
var t = {
score:0
}

const Rt = new Observable(t)
const handler = (newVal)=>{
console.log(“I am reactive, the new value is:”, newVal)
}
Rt.observe(“score”, handler)
```

You can add multiple handler like:
```
Rt.observe(“score”, handler1)
Rt.observe(“score”, handler2)
```

## Access the observable object:
`Rt.obj`

To change value, `Rt.obj.score = 500`

NOTE: This doesn't observe nested properties