DataService

public final class DataService : WebcomService
extension DataService: WebcomCombinable

An object representing the Data service of a WebcomApplication instance. This service consists of a database with a tree-like data model (equivalent to a JSON object).

To get an object of this type, use the WebcomApplication.dataService property of a WebcomApplication instance. There is only one instance of this class for each WebcomApplication instance.

This service uses a REST API of the back-end to read and write data. Unlike the DatasyncService, it is not real-time and it does not offer local caching. It is a low-level access.

This service should only be used when it is not possible to use the DatasyncService, especially in extensions where available resources are limited and where therefore the JavaScript SDK cannot be loaded.

When possible, it is always best to use the DatasyncService.

Stored Properties

API

  • Returns a reference to a database node.

    This method always succeeds. If the path is ill-formed, it is the methods of the resulting instance that will fail.

    The path consists of segments separated by / (slash) characters. Each segment corresponds to a move in the database tree:

    • The starting point is the root node of the database tree
    • The . segment is a no-operation.
    • The .. segment indicates to go one level up in the tree. When already at the root node, this is a no-operation.
    • The empty segment, when using a / at the beginning or at the end of the path, or when using several consecutive /, is a no-operation.
    • Any other valid segment indicates to go one level down towards the so-named child.

    Declaration

    Swift

    public func node(for path: String) -> DataNode

    Parameters

    path

    The absolute path of the node to refer. It can start or not with a / (slash) character. It is always absolute.

    Return Value

    A reference to the node corresponding to the path.

  • Update the device token of all subscriptions through remote notifications (push notifications) that are stored.

    If a subscription has failed, especially if the device token was not available at that time, it is still stored so that this method can (try to) update it. Subscriptions for which the device token has not changed are not affected by this method.

    Declaration

    Swift

    public func updateDeviceTokenInAllSubscriptions(file: StaticString = #fileID, line: UInt = #line, session: URLSession? = nil, queue: DispatchQueue? = nil, then completionCallback: (() -> Void)? = nil)

    Parameters

    file

    The file from which the method is called. This is used for debugging purposes.

    line

    The line from which the method is called. This is used for debugging purposes.

    session

    The session used to send the requests to the back-end. When nil, the default session of the application of this instance is used.

    queue

    The queue to which the provided callback dispatches. When nil, the default callback queue of the application of this instance is used.

    completionCallback

    The closure to call upon completion. It is always called with a void value.

  • Cancels all subscriptions through remote notifications (push notifications) that are stored.

    This method cancels subscriptions stored by the DataNode.subscribeThroughNotifications(descriptor:file:line:session:queue:then:) method.

    Declaration

    Swift

    public func unsubscribeFromAllThroughNotifications(session: URLSession? = nil, queue: DispatchQueue? = nil, then completionCallback: (() -> Void)? = nil)

    Parameters

    session

    The session used to send the requests to the back-end. When nil, the default session of the application of this instance is used.

    queue

    The queue to which the provided callback dispatches. When nil, the default callback queue of the application of this instance is used.

    completionCallback

    The closure to call upon completion. It is always called with a void value.

  • Cancels all subscriptions through webhooks that are stored.

    This method cancels subscriptions stored by the DataNode.subscribeThroughWebhook(descriptor:file:line:session:queue:then:) method.

    Declaration

    Swift

    public func unsubscribeFromAllThroughWebhook(session: URLSession? = nil, queue: DispatchQueue? = nil, then completionCallback: (() -> Void)? = nil)

    Parameters

    session

    The session used to send the requests to the back-end. When nil, the default session of the application of this instance is used.

    queue

    The queue to which the provided callback dispatches. When nil, the default callback queue of the application of this instance is used.

    completionCallback

    The closure to call upon completion. It is always called with a void value.

Combine Module

  • The type that wraps DataService in order to enrich it with a Combine-based API.

    See also the documentation section of WebcomWrapper for the corresponding wrapped type.

    To use this type, import the following dependency in your code:

    import WebcomCombine
    
    See more

    Declaration

    Swift

    public final class CombineWrapper : WebcomWrapper, Equatable, CustomDebugStringConvertible
  • The wrapping instance, which has a Combine-based API.

    Declaration

    Swift

    public var forCombine: CombineWrapper { get }