import { event } from '../../index' import type { EventState } from '../../index' import type { OnlineState } from './types' export * from './types' export const onlineEvent = () => { const change = () => { self.online = navigator.onLine self.snapshot = [self] self.callback() } const mount = () => { self.change() window.addEventListener('online', self.change) window.addEventListener('offline', self.change) } const clean = () => { window.removeEventListener('online', self.change) window.removeEventListener('offline', self.change) } const self = event({ change, mount, clean, }) as EventState self.snapshot = [self] return self }