Class: Callback

ServerlessDb.Callback

Represents the most realtime chanel for notifications, that is, a function that will be called at each watched data change. It relies on the realtime communication with the Webcom back end over the websocket managed by the associated ServerlessDb, and also manages the local cache of data for being able to work offline.

Instances of this class are built using the Callback method of the Webcom.ServerlessDb static property.

Methods

includeAcknowledgements() → {ServerlessDb.Callback}

Requires that the callback function will also be called on acknowledgement of data (without change) from the Webcom back end.

Returns:

This Callback instance updated, to allow chaining other methods.

Type
ServerlessDb.Callback

onCanceled(cancelationCallback) → {ServerlessDb.Callback}

Defines a function that will be called when the associated subscription will be canceled (either by user abortion or by server revocation).

If the passed cancelationCallback doesn't return undefined, then the returned value overrides the cancellationPolicy passed to the constructor of this ServerlessDb.Callback.

Parameters:
Name Type Description
cancelationCallback ServerlessDb.CancelationCallback

The callback receives either null (explicit abortion by the app) or an Error object (revocation by the Webcom back end) and may return a specific cache-control policy.

Returns:

This Callback instance updated, to allow chaining other methods.

Type
ServerlessDb.Callback

Type Definitions

Factory(callback, cancelationPolicyopt) → {ServerlessDb.Callback}

Function that creates an instance of ServerlessDb.Callback notification channel, which is intended to be registered with the ServerlessDb.ServerlessDbNode#subscribe method and to receive notifications of data changes in real time (through the ServerlessDb websocket).

Such a function is available through the Callback property of the Webcom.ServerlessDb property.

Parameters:
Name Type Attributes Default Description
callback ServerlessDb.SubscriptionCallback

The function that will receive notifications each time the subscribed event is raised.

cancelationPolicy ServerlessDb.FORGET | ServerlessDb.KEEP | ServerlessDb.KEEP_UPDATING <optional>
ServerlessDb.KEEP

The policy to apply on the local cache when the corresponding subscription will end.

Since:
  • 3.5
Returns:
Type
ServerlessDb.Callback
show
deprecated