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