package.src.store.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alpinejs Show documentation
Show all versions of alpinejs Show documentation
The rugged, minimal JavaScript framework
The newest version!
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
initInterceptors(stores[name])
if (typeof value === 'object' && value !== null && value.hasOwnProperty('init') && typeof value.init === 'function') {
stores[name].init()
}
}
export function getStores() { return stores }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy