why deepstreamHub? compare us getting started feature roadmap faq
use cases pricing
products
developers
company
blog contact

The factory method's for deepstreamHub's realtime datastore concepts, such as getRecord(recordName), getList(_:), provider functionality such as listen(_:listener:) and single requests like snapshot(_:)

Methods

getRecord(_:)

cass func getRecord(_ recordName: String) -> Self
argument type description
recordName String The name of the record to get

Returns an existing record or creates a new one. If creating a new one the record will not be in a ready state till it is loaded from the server.

Show example...

getList(_:)

class func getList(_ listName: String) -> List
argument type description
listName String The name of the list to retrieve

Returns an existing List or creates a new one. A list is a specialised type of record that holds an array of recordNames.

Show example...

getAnonymousRecord()

class func getAnonymousRecord() -> AnonymousRecord

Returns an AnonymousRecord. An anonymous record is effectively a wrapper that mimicks the API of a record, but allows for the underlying record to be swapped without losing subscriptions etc.

This is particularly useful when selecting from a number of similarly structured records. E.g. a list of users that can be choosen from a list.

The only API differences to a normal record is an additional setName(_:) method.

snapshot(_:)

class func snapshot(_ recordName: String) -> SnapshotResult
argument type description
recordName String The name of the record which data to retrieve

Retrieves a SnapshotResult with the current record data. Using this doesn't subscribe the client to changes the way getRecord(name) does.

Show example...

has(_:)

class func has(_ recordName: String) throws -> Bool
argument type description
recordName String The name of the record to check

Returns a HasResult that shows whether or not the record exists.

Show example...

listen(_:listener:)opensource / enterprise

class func listen(_ pattern: String, listenCallback: ListenListener) -> Void
argument type description
pattern String The pattern to match events which subscription status you want to be informed of
listener ListenListener The Listen Listener

Allows to listen for record subscriptions made by this or other clients. This is useful to create "active" data providers, e.g. providers that only provide data for a particular record if a user is actually interested in it.

You can only listen to a pattern once, and if multiple listeners match the same pattern only a single one will be notified.

Show example...

unlisten(_:)opensource / enterprise

void unlisten(_ pattern: String)
argument type description
pattern String The pattern that has been previously listened to

Remove the listener added via listen(_:listener:). This will remove the provider as the active provider and allow another provider to take its place.

Show example...