1.0.2 • Published 5 years ago

reactiveobj v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

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

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago