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

16 lines
306 B
JavaScript
Raw Normal View History

2021-06-24 22:40:29 +00:00
import { createStore, getValue } from 'nanostores';
const counter = createStore(() => {
2021-06-24 22:40:29 +00:00
counter.set(0);
});
function increaseCounter() {
2021-06-24 22:40:29 +00:00
counter.set(getValue(counter) + 1);
}
function decreaseCounter() {
2021-06-24 22:40:29 +00:00
counter.set(getValue(counter) - 1);
}
2021-06-24 22:40:29 +00:00
export { counter, increaseCounter, decreaseCounter };