update readme

This commit is contained in:
dntzhang 2018-12-12 18:01:31 +08:00
parent 16c2ad5d54
commit b6c53b43a6
2 changed files with 4 additions and 5 deletions

View File

@ -14,7 +14,7 @@ npm install obaa
```js
var obj = { a: 1 };
observe(obj, function (name, value , old) {
obaa(obj, function (name, value , old) {
console.log(name + "__" + value + "__" + old);
});
obj.a = 2; //a__2__1
@ -24,7 +24,7 @@ obj.a = 2; //a__2__1
```js
var arr = [1, 2, 3];
observe(arr, function (name, value, old) {
obaa(arr, function (name, value, old) {
console.log(name + "__" + value+"__"+old);
});
arr.push(4);//Array-push__[1,2,3,4]__[1,2,3]
@ -38,7 +38,7 @@ var User = function (name, age) {
this.name = name;
this.age = age;
//observe name only
observe(this, ["name"], function (name, value, oldValue) {
obaa(this, ["name"], function (name, value, oldValue) {
console.log(name + "__" + value + "__" + oldValue);
});
}
@ -49,7 +49,6 @@ user.age = 20; //nothing output
## Other
```js
arr.push(111) //trigger observe callback
//every method of array has a pureXXX function

View File

@ -1,6 +1,6 @@
{
"name": "obaa",
"version": "1.0.0",
"version": "1.0.1",
"description": "Observe any object's any change.",
"main": "index.js",
"scripts": {