- Since:
- 2.11
Members
(readonly) currentState :DatasyncService.State
The current state of the real-time connection to the Webcom back end managed by this instance of
DatasyncService
. This property returns the same value as the virtual data node at the special
".info"
path.
Type:
(readonly) offlineData
Returns the currently available data in the local cache, encoded into a string. It is intended to be saved
somewhere by the client before shutting down the application, and then provided back to the application at start,
through the "offlineData"
property of the options passed to the Webcom
constructor.
(readonly) options :DatasyncService.Options
Gives the options that were used to build this DatasyncService
instance.
Type:
(readonly) shouldBeConnected :boolean
Returns the current expected connection state to the Webcom back end managed by this
DatasyncService
instance:
true
means it should be connected, however it may not be the case if the device network connectivity is down. The actual connection state is given by theconnection.connected
property of theDatasyncService#currentState
member.false
means it should be disconnected. The value of this property is driven by calls to theDatasyncService#connect
andDatasyncService#disconnect
methods.
Type:
- boolean
Methods
cleanOfflineData()
Removes from the local cache all data that don't result from a currently ongoing subscription.
This means that all data preserved until now following calls to the Query#offPreservingOfflineData
method are lost and will no longer be available offline.
connect()
Forces the establishment of the real-time connection to the Webcom back end managed by this
DatasyncService
instance and enables the retry connection feature.
If the device has network connectivity, calling this method should end in switching the connection.connected
property of DatasyncService#currentState
to true
. However, this property will remain false
as long
as the network or the Webcom back end is unavailable.
disconnect()
Forces the interruption of the real-time connection to the Webcom back end managed by this
DatasyncService
instance and disables the retry connection feature. The connection will not be
reestablished until DatasyncService#connect
is called.
persist() → {boolean}
Persists the content of the local cache. It actually stores the value returned by
DatasyncService#offlineData
into the local storage.
Note: if the persist
option of this DatasyncService
instance is not set to true
or the running
client is not a regular browser, this method has no effect.
Returns:
true
if the local cache could be persisted, or false
otherwise.
- Type
- boolean
Type Definitions
Options
Type:
- Object
Properties:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
persist |
boolean |
<optional> |
false | Indicates whether the local cache content can be persisted using the
|
||||||||||||||||||||
connect |
boolean |
<optional> |
true | Indicates whether the real-time connection to the Webcom back end should be
established at startup. If |
||||||||||||||||||||
completeSubscriptionOnCancelation |
boolean |
<optional> |
false | (Since 2.14.1) |
||||||||||||||||||||
websocket |
Object |
<optional> |
Specifies the options that control the establishment of the real-time connection to the Webcom back end (advanced use only): Properties
|
- Since:
- 2.11
State
Represents the current state of a DatasyncService
instance. It can be retrieved by either getting the
DatasyncService#currentState
property or watching the ".info"
virtual data node (using the
Webcom#on
method).
Type:
- Object
Properties:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reachable |
boolean |
<optional> |
Indicates whether the hosting device has network connectivity, independently of the establishment of the real-time connection to the Webcom back end. |
||||||||||||
connected |
boolean | Deprecated: use the |
|||||||||||||
serverTimeOffset |
number |
<optional> |
Deprecated: use the |
||||||||||||
connection |
Object | Gives some information about the real-time connection to the Webcom back end: Properties
|
|||||||||||||
authenticated |
boolean |
|
|||||||||||||
authentication |
AuthenticationService.State | Reports the authentication state validated on
the real-time connection to the Webcom back end. This property may be slightly delayed wrt.
|
- Since:
- 2.11