Options
All
  • Public
  • Public/Protected
  • All
Menu

Ditto JS SDK v1.0.18-alpha1

Index

Type aliases

AttachmentFetchEvent

A representation of the events that can occur in relation to an attachment fetch.

There are three different attachment fetch events: Completed, Progress, or Deleted.

There will be at most one Completed or Deleted event per attachment fetch. There can be many Progress events delivered for each attachment fetch.

Updates relating to an attachment fetch are delivered by registering an AttachmentFetcher through a call to fetchAttachment() on a Collection instance.

AttachmentFetchEventCompleted

AttachmentFetchEventCompleted: { attachment: Attachment; type: "Completed" }

An attachment fetch event used when the attachment's download has completed.

Type declaration

AttachmentFetchEventDeleted

AttachmentFetchEventDeleted: { type: "Deleted" }

An attachment fetch event used when the attachment is deleted.

Type declaration

  • type: "Deleted"

AttachmentFetchEventProgress

AttachmentFetchEventProgress: { downloadedBytes: number | BigInt; totalBytes: number | BigInt; type: "Progress" }

An attachment fetch event used when the attachment's download progressed but is not yet complete.

Type declaration

  • downloadedBytes: number | BigInt
  • totalBytes: number | BigInt
  • type: "Progress"

AttachmentFetchEventType

AttachmentFetchEventType: "Completed" | "Progress" | "Deleted"

The types of attachment fetch events that can be delivered to an attachment fetcher's callback.

ConditionSource

ConditionSource: "BLE" | "TCP" | "AWDL" | "MDNS"

The source for a transport condition.

CustomLogCallback

CustomLogCallback: (logLevel: LogLevel, message: string) => void

Type declaration

DocumentIDValue

DocumentIDValue: any

Represents a unique identifier for a Document.

DocumentLike

DocumentLike: Document | DocumentValue | any

This is used whenever you can access the document content properties directly via the document.

DocumentValue

DocumentValue: Record<string, any>

A document value is a JavaScript object containing values for keys that can be serialized via CBOR.

Identity

The various identity configurations that you can use when initializing a Ditto instance.

InitOptions

InitOptions: { webAssemblyModule?: WebAssemblyModule }

Available options for init().

Type declaration

  • Optional webAssemblyModule?: WebAssemblyModule

    You can explicitly pass the WebAssembly module or its location via the webAssemblyModule option. By default, Ditto tries to load the WebAssembly module from the same path where this JavaScript is served.

InsertOptions

InsertOptions: { id?: any; isDefault?: boolean; writeStrategy?: WriteStrategy }

Type declaration

  • Optional id?: any
  • Optional isDefault?: boolean
  • Optional writeStrategy?: WriteStrategy

LiveQueryEvent

Represents events delivered by a LiveQuery, which can be initial (fired immediately upon registration) or an update (all subsequent events).

LogLevel

LogLevel: "Error" | "Warning" | "Info" | "Debug" | "Verbose"

The log levels supported by Ditto.

MutableDocumentLike

MutableDocumentLike: MutableDocument | DocumentValue | any

This is used whenever you can access and update the document content properties directly via the document.

PresenceConnectionType

PresenceConnectionType: "WiFi" | "WebSocket" | "AWDL" | "BLE"

Types of connections that can be established between two peers.

QueryArguments

QueryArguments: {}

Represents a dictionary of values to be incorporated into a query keyed by the placeholder used within that query. See method find() of Collection for more info.

Type declaration

  • [key: string]: any

QueryObservationHandler

QueryObservationHandler: (documents: DocumentLike[], event: LiveQueryEvent, signalNext?: () => void) => void | Promise<void>

Type declaration

    • The closure that is called whenever the documents covered by a live query change.

      Parameters

      Returns void | Promise<void>

RemotePeer

RemotePeer: { approximateDistanceInMeters?: number; connections: PresenceConnectionType[]; deviceName: string; networkID: string; rssi?: number }

A peer object with information about an observed peer.

Type declaration

  • Optional approximateDistanceInMeters?: number
  • connections: PresenceConnectionType[]
  • deviceName: string
  • networkID: string
  • Optional rssi?: number

SingleObservationHandler

SingleObservationHandler: (document: DocumentLike | null, event: SingleDocumentLiveQueryEvent, signalNext?: () => void) => void | Promise<void>

Type declaration

SortDirection

SortDirection: "ascending" | "descending"

Describes the direction when sorting a query.

SubscriptionContextInfo

SubscriptionContextInfo: { collectionName: string; ditto: Ditto; query: string; queryArgsCBOR: Uint8Array | null }

Type declaration

  • collectionName: string
  • ditto: Ditto
  • query: string
  • queryArgsCBOR: Uint8Array | null

TransportCondition

TransportCondition: "Unknown" | "OK" | "GenericFailure" | "AppInBackground" | "MDNSFailure" | "TCPListenFailure" | "NoBLECentralPermission" | "NoBLEPeripheralPermission" | "CannotEstablishConnection" | "BLEDisabled" | "NoBLEHardware" | "WiFiDisabled" | "TemporarilyUnavailable"

Types of connections that can be established between two peers.

UpdateResultType

UpdateResultType: "set" | "replacedWithCounter" | "incremented" | "inserted" | "removed" | "pushed" | "popped"

The types of an UpdateResult.

WebAssemblyModule

WebAssemblyModule: RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null

Various options to pass the web assembly module to Ditto.

WriteStrategy

WriteStrategy: "merge" | "overwrite" | "insertIfAbsent" | "insertDefaultIfAbsent"

Defines the various strategies available when inserting a document into a collection.

Variables

attachmentBridge

attachmentBridge: Bridge<Attachment, "AttachmentHandle_t">

Functions

init

  • Initializes the whole Ditto module. Needs to be called and complete before any of the Ditto API is used.

    Parameters

    Returns Promise<void>