Skip to main content
Version: v7.0.0

useAppManager

Read the API Reference »

useAppManager allows you to use information about the connection status and screen focus state. It also offers options to manipulate its global state. This hook uses the AppManager available on the Client instance.

It returns the status of isOnline and isFocused and the actions that allow you to change them.


Purpose
  1. Controls application online/offline state
  2. Controls application window focus/blur state

Usage

Here is a simple example of how to use the useAppManager hook.

Get the connection status

Online state is the information if application is connected to the internet or not.

const { isOnline, setOnline } = useAppManager(client);

setOnline(true);

Get the screen focus state

Focus state is the information if user is currently using the application or not.

const { isFocused, setFocused } = useAppManager(client);

setFocused(true);

State and methods

This hook returns the following values.

const values = useAppManager(client);

useAppManager
Name Type Description
isFocused
boolean
Is window focused
isOnline
boolean
Network online status
setFocused
(isFocused: boolean) => void
Focus state setter
setOnline
(isOnline: boolean) => void
Network state setter