Options
Menu

The IConvergenceOptions interface represents that options that can be set within Convergence when connecting to a domain.

See the ConvergenceOptions implementation for the default settings.

Hierarchy

  • IConvergenceOptions

Index

Properties

connection

connection: { connectionRequestTimeout?: number; timeout?: number }

Options that configure the connection strategy.

Type declaration

  • connectionRequestTimeout?: number

    The maximum time in seconds to wait for a successful connection request to be completed. The default value is 10 seconds.

  • timeout?: number

    The maximum time in seconds to wait for a successful web socket connection to be made. The default value is 5 seconds.

models

models: { data?: { undefinedArrayValues?: "error" | "null"; undefinedObjectValues?: "error" | "omit" } }

Configures the model subsystem.

Type declaration

  • data?: { undefinedArrayValues?: "error" | "null"; undefinedObjectValues?: "error" | "omit" }

    Configure how data is handled within models.

    • undefinedArrayValues?: "error" | "null"

      Determines what happens when data is supplied that contains an array that contains undefined at one or more indices. If set to "error" (the default) the client will throw an error if if it detects an undefined value within an array. If set to "null", the value will be converted to null.

    • undefinedObjectValues?: "error" | "omit"

      Determines what happens when data is supplied to an object that contains a property with a value of undefined. If set to "error" (the default) the client will throw an error if if it detects an undefined value in an object. If set to "omit", the property will simply be omitted from the resultant RealTimeObject.

offline

offline: { modelSnapshotInterval?: number; storage: IStorageAdapter }

Configures offline storage for Convergence. Several of these options are required to enable offline editing of data.

experimental

Type declaration

  • modelSnapshotInterval?: number

    The number of operations after which a snapshot of local offline that is being edited should be taken. The default is 100.

    experimental
  • storage: IStorageAdapter

    The storage adapter to use for offline storage.

    experimental

protocol

protocol: { defaultRequestTimeout: number; heartbeat?: { enabled: boolean; pingInterval?: number; pongTimeout?: number } }

Configures the behavior of the messaging protocol subsystem.

Type declaration

  • defaultRequestTimeout: number

    The timeout for a request to the server, in seconds. The default value is 10 seconds.

  • heartbeat?: { enabled: boolean; pingInterval?: number; pongTimeout?: number }

    Configures the keep-alive heartbeat.

    • enabled: boolean

      Determines if the heartbeat is enabled.

    • pingInterval?: number

      Configures how long the client will wait, in seconds after the last message is received from the server before a ping will be sent. The default value is 5 seconds.

    • pongTimeout?: number

      Specifies the time in seconds the client will wait for a response from the server to a ping before considering the connection dead. The default value is 10 seconds.

reconnect

reconnect: { autoReconnect?: boolean; autoReconnectOnInitial?: boolean; fallbackAuth?: (authChallenge: IFallbackAuthChallenge) => void; reconnectIntervals?: number[] }

Options that configure how Convergence will reconnect when an established connection is lost unexpectedly or when the intial connection fails.

Type declaration

  • autoReconnect?: boolean

    Whether to automatically reconnect when the connection is unexpectedly dropped. Note this setting only applies to connections that have succeeded and then were lost. This setting does not apply to the initial connection, or the first connection made after disconnect is called on the domain. Default is true.

  • autoReconnectOnInitial?: boolean

    Whether to automatically reconnect if the initial connection fails. Setting this to false will prevent Convergence from reconnecting automatically if the initial connection (as requested by directly calling one of the connect methods), but will still allow Convergence to reconnect if it was disconnected unintentionally after the first connection was made. Note that if a connection is successful, and then disconnect is called, the subsequent call to connect will be treated as an initial connection. Default is true.

  • fallbackAuth?: (authChallenge: IFallbackAuthChallenge) => void

    The fallbackAuth method to use when a reconnect token is rejected. It provides the opportunity to use a fallback method of authentication.

    options.reconnect.fallbackAuth = (authChallenge:IFallbackAuthChallenge) => {
      return YourAuthenticationService.getNewJwt().then(jwt => {
        authChallenge.jwt(jwt);
      })
    };
    
  • reconnectIntervals?: number[]

    The intervals to use between reconnects. This array will be sorted from smallest to largest. When the largest interval is reached it will simply be repeated.

webSocket

webSocket: { class?: IWebSocketClass; factory?: WebSocketFactory }

Options that configure how Convergence will use WebSockets.

See the Node.js Usage section on [this page] for an example of these parameters in action.

Type declaration

  • class?: IWebSocketClass

    The constructor to use when creating a web socket. Essentially this is class that should be used to represent the web socket.

  • factory?: WebSocketFactory

    Defines the class / constructor that should be used to create WebSocket objects. This is useful when operating in NodeJS where a library like ws or isomorphic-ws can be used to provide a client side WebSocket API.