api.ts 378 B

12345678910111213141516171819
  1. import { loadingStore } from "./store";
  2. export const overlayLoading = {
  3. start() {
  4. const s = loadingStore.getSnapshot();
  5. loadingStore.setState({ count: s.count + 1 });
  6. },
  7. stop() {
  8. const s = loadingStore.getSnapshot();
  9. loadingStore.setState({
  10. count: Math.max(0, s.count - 1),
  11. });
  12. },
  13. reset() {
  14. loadingStore.setState({ count: 0 });
  15. },
  16. };