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

16 lines
327 B
JavaScript
Raw Normal View History

import { atom } from 'nanostores';
const initialValue = { value: 0 };
const counter = atom(initialValue);
function increaseCounter() {
2021-12-22 21:11:05 +00:00
counter.set({ value: counter.get().value + 1 });
}
function decreaseCounter() {
2021-12-22 21:11:05 +00:00
counter.set({ value: counter.get().value - 1 });
}
2021-06-24 22:40:29 +00:00
export { counter, increaseCounter, decreaseCounter };