Skip to main content
Version: 4.x.x

Offline

We created this library with offline and data persistence in mind, thanks to this approach our queues, which are responsible for sending and processing requests, are fully prepared for creating offline-first applications.

Currently, the operation of this system is default, which means that the offline mechanics are queued and completely automated. Receiving the information that the application has entered the offline state, we automatically stop the requests being executed or queued, and then resume them when the connection is restored.

The offline operation is greatly influenced by one of the managers - AppManager, which is responsible for emitting events related to the current state of the application - such as offline / online or focused / blurred.


Custom offline events

Let's take React Native as an example. The default events detecting whether our application has entered the offline / online state are based on the window event listeners, when we are talking about a native implementation, we must use NetInfo as the source of the connection state.

export const client = new Client<ServerErrorType>({
url: environment.serverUrl,
appManager: (instance) =>
new AppManager(instance, {
initiallyOnline: async () => {}
onlineEvent: (setOnline) => {}
}),
});