简单模型(easy-model)
一个简单的状态管理包.
A simple state management lib for Typescript
例子(Example)
import { provide, subscribe } from "@e7w/easy-model";
const A = provide(
class A {
msg = "1";
constructor(private id: number) {}
random() {
this.msg = `${Math.random()}`;
}
}
);
A(1) === A(1); // true
A(1) !== new A(1); // true
subscribe(A(1), console.log.bind(console, "Path of changed value:"));
const { random } = A(1);
random(); // Path of changed value: ["msg"]