UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

40 lines 997 B
/** * Create a reactive network status tracker * * @example * ```ts * const network = useNetwork() * * network.subscribe((state) => { * if (state.isOffline) { * showOfflineMessage() * } * }) * * if (network.effectiveType === '2g') { * loadLowQualityImages() * } * ``` */ export declare function useNetwork(): NetworkRef; /** * Simple online/offline tracker */ export declare function useOnline(): { isOnline: boolean; subscribe: (cb: (online: boolean) => void) => () => void }; /** * useNetwork - Reactive network status composables * * Provides reactive tracking of network connectivity and information. */ export declare interface NetworkState { isOnline: boolean isOffline: boolean type: string | null effectiveType: '2g' | '3g' | '4g' | 'slow-2g' | null downlink: number | null rtt: number | null saveData: boolean } export declare interface NetworkRef extends NetworkState { subscribe: (callback: (state: NetworkState) => void) => () => void }