useAppManager
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
- Controls application online/offline state
- 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 |
| Is window focused |
isOnline |
| Network online status |
setFocused |
| Focus state setter |
setOnline |
| Network state setter |