import { loadingStore } from "./store";

export const overlayLoading = {
  start() {
    const s = loadingStore.getSnapshot();
    loadingStore.setState({ count: s.count + 1 });
  },

  stop() {
    const s = loadingStore.getSnapshot();
    loadingStore.setState({
      count: Math.max(0, s.count - 1),
    });
  },

  reset() {
    loadingStore.setState({ count: 0 });
  },
};