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.
the path of the topic
the type of the values expected by the update stream
optional options object
an update stream
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.
the path of the topic
the type of the values
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
.
optional options object
a Result that resolves when a response is received from the server.
If the task fails, the Result will resolve with an
Error
.
This feature provides a client session with the ability to update topics.
A session does not have to be subscribed to a topic to update it.
Constraints can be applied to the setting of a value and creation of an update stream. Constraints describe a condition that must be satisfied for the operation to succeed. The constraints are evaluated on the server. The available constraints are: an active session lock, the current value of the topic being updated and a part of the current value of the topic being updated.
When a topic of type STRING, INT64 or DOUBLE is set to
null
orundefined
, the topic will be updated to have no value. If a previous value was present subscribers will receive a notification that the new value isundefined
. New subscribers will not receive a value notification. Attempting to set any other type of topic tonull
orundefined
will cause anError
to be thrown.Access control
To update any topic a session needs update topic permission covering the topic. To create any topic a session needs modify topic permission covering the topic. Requests that combine adding a topic and setting the value will require both permissions for either action to happen. An UpdateStream cannot be used to add a topic successfully but fail to set its value because the update topic is missing.
Accessing the feature
This feature may be obtained from a session as follows:
var topicUpdate = session.topicUpdate;
6.2