AppManager
App manager handles main application states - focus and online. Those two values can answer questions:
- Is the tab or current view instance focused and visible for user?
- Is our application online or offline? With the app manager it is not a problem to get the valid answer for this question.
Import
import { AppManager } from "@hyper-fetch/core"
Source
Package
Parameters
class AppManager {
constructor(options: AppManagerOptionsType) {};
options: AppManagerOptionsType;
isOnline: boolean;
isFocused: boolean;
isBrowser: boolean;
events: { emitBlur: () => void; emitFocus: () => void; emitOffline: () => void; emitOnline: () => void; onBlur: (callback: () => void) => VoidFunction; onFocus: (callback: () => void) => VoidFunction; onOffline: (callback: () => void) => VoidFunction; onOnline: (callback: () => void) => VoidFunction };
emitter: EventEmitter;
initialize() => void;
setFocused(isFocused: boolean) => void;
setOnline(isOnline: boolean) => void;
unmount() => void;
}
Parameters
| Name | Type | Description |
|---|---|---|
| options | |
Properties
events
Source
Type
{ emitBlur: () => void; emitFocus: () => void; emitOffline: () => void; emitOnline: () => void; onBlur: (callback: () => void) => VoidFunction; onFocus: (callback: () => void) => VoidFunction; onOffline: (callback: () => void) => VoidFunction; onOnline: (callback: () => void) => VoidFunction }
Methods
initialize()
Subscribes to the environment focus and network changes. Calling it again replaces the previous subscriptions, so the listeners are never registered twice.
Source
Preview
initialize()
Returns
void
setFocused()
Source
Preview
setFocused(isFocused: boolean)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| isFocused | |
Returns
void
setOnline()
Source
Preview
setOnline(isOnline: boolean)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| isOnline | |
Returns
void
unmount()
Removes the environment listeners registered by
initialize()
. Listeners added with
events
are kept.
Source
Preview
unmount()
Returns
void

