narupatools.state.view.view

A view to a shared state, which does not contain data explicitly.

A shared state dictionary is constantly updating, but it is useful to keep track of references to individual keys.

A SharedStateView represents a view to a SerializableDictionary, with more useful utility methods than the simple wrapper SharedStateClientWrapper and SharedStateServerWrapper. When setting keys, either a normal Serializable value can be provided, or alternatively any object which implements SerializableObject. This removes the onus from the user from having to explicitly convert certain objects such as selections into a serializable form before insertion into the dictionary.

Because the dictionary could be changing, accessing a key directly through the view does not actually read the value from the dictionary. Instead, it returns a SharedStateReference, which stores both the key you requested and the dictionary itself. For more information, see the documentation for SharedStateReference.

A reference to a whole set of keys with a common prefix can be obtained by using the collection() method.

A snapshot of the current state of the dictionary can be obtained by calling the snapshot() method. This returns a copy of the dictionary, which is no longer tied to the original and hence is a snapshot of its value at that point in time.

Classes

SharedStateView(dictionary, Union[None, str, …)

Represents a view of a shared state dictionary.