Inject

inject any class, which both created by combineStore.

1
import { inject, combineStore } from "dob"

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class A {
value = 5
}

class B {
@inject(A) a

showValue() {
return this.a.value
}
}

const stores = combineStore({A, B})

console.log(stores.B.showValue()) // 5
stores.A.value = 6
console.log(stores.B.showValue()) // 6