astro/examples/astro-nanostores/src/store/counter.js

19 lines
305 B
JavaScript
Raw Normal View History

import { createStore, getValue } from 'nanostores'
const counter = createStore(() => {
counter.set(0)
})
function increaseCounter() {
counter.set(getValue(counter) + 1)
}
function decreaseCounter() {
counter.set(getValue(counter) - 1)
}
export {
counter,
increaseCounter,
decreaseCounter
}