blob: dc7bf94f57187da1a79b09ddda6e53fbe387fafd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { initInterceptors } from "./interceptor";
import { reactive } from "./reactivity"
let stores = {}
let isReactive = false
export function store(name, value) {
if (! isReactive) { stores = reactive(stores); isReactive = true; }
if (value === undefined) {
return stores[name]
}
stores[name] = value
if (typeof value === 'object' && value !== null && value.hasOwnProperty('init') && typeof value.init === 'function') {
stores[name].init()
}
initInterceptors(stores[name])
}
export function getStores() { return stores }
|