import { writable } from "svelte/store"

/**
 * Global store to track active API requests
 * Used to display global loading indicator
 */
export const activeRequests = writable<number>(0)

/**
 * Increment active requests counter
 */
export function incrementRequests() {
    activeRequests.update((count) => count + 1)
}

/**
 * Decrement active requests counter
 */
export function decrementRequests() {
    activeRequests.update((count) => Math.max(0, count - 1))
}
