Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
y1j2x34 committed Nov 11, 2017
1 parent 3f0568d commit e2f951a
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions README.md
Expand Up @@ -187,23 +187,42 @@ flyingPuppy.smile();// smilling puppy

### Proxy


```js
var Cat = Class.create({
miao: function(){
console.info('miao~~~');
return 'miao';
meow: function(){
console.info('meow~~~');
return 'meow';
}
});

// proxy object
var cat = new Cat();
var proxy = Class.proxy(cat, function(originObject, func, args){
console.info('before~');
var ret = func.apply(originObject, arg);
console.info('after~');
return ret;
});
proxy.miao(); // returns 'miao'
proxy.meow(); // returns 'meow'
// output:
// before~
// meow~~~
// after~

// proxy class
var ProxyCat = Class.proxy(Cat, function(originalObject, func, args){
console.info('before~');
var ret = func.apply(originObject, arg);
console.info('after~');
return ret;
});

new ProxyCat().meow();
// output:
// before~
// miao~~~
// meow~~~
// after~


```

0 comments on commit e2f951a

Please sign in to comment.