Despia fires globalDocumentation Index
Fetch the complete documentation index at: https://setup.despia.com/llms.txt
Use this file to discover all available pages before exploring further.
window.focusin() and window.focusout() callbacks whenever the app moves between foreground and background. Define these functions in your web code to react to lifecycle changes such as resuming sessions, refreshing data, or pausing media.
Installation
- Bundle
- CDN
How it works
The native runtime invokeswindow.focusin() when the app returns to the foreground and window.focusout() when it leaves. Attach handlers directly to the window object to receive these events.
focusout callback fires once per background transition. The focusin callback fires every time the app returns to the foreground, including the first launch resume.
Refresh data on resume
Usefocusin to revalidate session state or pull fresh content when the user returns to the app.
Pause activity on background
Usefocusout to stop timers, pause video playback, or persist unsaved state before the app is suspended.
Track session duration
Combine both events to measure how long the user stays inside the app per session.Resources
NPM Package
despia-native