1.1.6 • Published 4 years ago
que-proxyable v1.1.6
que-proxyable 使用说明
一个简单的使用 proxy 代理对象的库,并能够进行监听。
简单使用
import { Proxyable, ProxyWatcher } from 'que-proxyable';
const data = Proxyable({ a: 100 });
const watcher = new ProxyWatch();
const unsub = watcher.onGet((t, k) => console.log(t, k));
data.a = 1000; // print value of t and k
unsub();
data.a = 2000; // print nothing
进阶使用
State
import { State, ProxyWatcher } from 'que-proxyable';
class A {
@State()
count = 1;
}
const watcher = new ProxyWatcher();
watcher.onGet((t, k) => console.log(k));
const a = new A();
a.count;
// k's value count will print
Compute
import { State, Compute } from 'que-proxyable';
class A {
@State()
count = 1;
age = 1;
@Compute()
show() {
this.age++;
return this.count;
}
}
const a = new A();
a.show();
console.log(a.age); // 2
a.show();
console.log(a.age); // still 2
a.count++;
console.log(a.age); // still 2
a.show();
console.log(a.age); // 3
1.1.6
4 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago