UNPKG

@amityco/ts-sdk

Version:

Amity Social Cloud Typescript SDK

16 lines (13 loc) 570 B
export const onOnline = (callback: () => void) => { if (typeof window !== 'undefined' && window.addEventListener) { window.addEventListener('online', callback); return () => window.removeEventListener('online', callback); } if (typeof document !== 'undefined' && document.addEventListener) { document.addEventListener('online', callback); return () => document.removeEventListener('online', callback); } // Handle unsupported environment console.error('Unsupported environment'); return () => console.error('Unsupported environment'); };