Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TopicUpdateImpl

The implementation of the TopicUpdate feature

Hierarchy

  • TopicUpdateImpl

Implements

Index

Constructors

constructor

  • Create a new instance of the TopicUpdate feature

    Parameters

    Returns TopicUpdateImpl

Properties

Private ADD_AND_SET_TOPIC

The command service for adding a topic and setting its value

Private APPLY_JSON_PATCH

The command service for adding a topic and setting its value

Private SET_TOPIC

SET_TOPIC: ServiceSender<SetTopicRequest, null>

Command service for setting a topic value

Private updateStreamFactory

updateStreamFactory: UpdateStreamFactory

The factory for creating update streams

Methods

Private addAndSetTopic

  • Add a topic and set the topic value

    Parameters

    • path: string

      the path of the topic

    • specification: TopicSpecification

      the topic specification

    • dataType: AbstractDataType<any, any, any>

      the type of the values

    • value: any

      the value. String, int64, and double topics accept null or undefined , as described above. Using null or undefined with other topic types is an error and will throw an Error .

    • constraint: UpdateConstraint

      the topic update constraint

    Returns Result<TopicCreationResult>

    a result that completes with the topic creation result when the operation succeeds

applyJsonPatch

createUpdateStream

  • Creates an update stream to use for updating a specific topic.

    The type of the topic being updated must match the type derived from the dataType parameter.

    Update streams send a sequence of updates for a specific topic. They can result in more efficient use of the network as only the differences between the current value and the updated value are transmitted. They do not provide exclusive access to the topic. If exclusive access is required update streams should be used with session locks as constraints.

    Streams are validated lazily when the first set or validate operation is completed. Once validated a stream can be invalidated, after which it rejects future updates.

    Example:

    const stream = session.topicUpdate.createUpdateStream('my_topic', diffusion.datatypes.string());
    stream.set('hello');

    Parameters

    Returns UpdateStream

    an update stream

set

  • Sets the topic to a specified value.

    null or undefined can only be passed to the value parameter when updating STRING, INT64 or DOUBLE topics.

    When a topic of type STRING, INT64 or DOUBLE is set to null or undefined , the topic will be updated to have no value. If a previous value was present subscribers will receive a notification that the new value is undefined . New subscribers will not receive a value notification.

    Example:

    session.topicUpdate.set('my_topic', diffusion.datatypes.string(), 'hello');

    Parameters

    Returns Result<any>

    a Result that resolves when a response is received from the server.

    If the task fails, the Result will resolve with an Error .

Private setTopic

  • Set topic value for an existing topic

    Parameters

    • path: string

      the path of the topic

    • dataType: AbstractDataType<any, any, any>

      the type of the values

    • value: any

      the value. String, int64, and double topics accept null or undefined , as described above. Using null or undefined with other topic types is an error and will throw an Error .

    • constraint: UpdateConstraint

      the topic update constraint

    Returns Result<void>

    a result that completes when the operation succeeds