SharedStateView¶
-
class
narupatools.app.shared_state.SharedStateView(dictionary: MutableMapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]])¶ View of a shared state, which supports callbacks for when keys are changed.
Inheritance

Methods
Create a new view.
Remove all keys in this dictionary.
Get a collection view for all keys with the given prefix.
Get a reference to a specific key.
Get the current value, and apply changes after it is modified.
Trigger callbacks based on changes to a shared state dictionary.
Callback when a new item is added to the shared state.
Callback when an item is modified in the shared state.
Callback when an item is removed from the shared state.
Insert a value into the shared state.
Return a snapshot of each of the current items in this collection.
Update a value by adding the provided key-value pairs.
-
__init__(dictionary: MutableMapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]])¶ Create a new view.
- Parameters
dictionary – Shared state dictionary this is a view of.
-
collection(prefix: str, snapshot_type: Optional[Type[narupatools.state.serializable_object.SerializableObject]] = None, /) → narupatools.state.view.collection_view.SharedStateCollectionView¶ Get a collection view for all keys with the given prefix.
-
get(key: str, snapshot_type: Optional[Type[TSerializableObjectType]] = None, /) → narupatools.state.view.reference.SharedStateReference¶ Get a reference to a specific key.
-
items() → a set-like object providing a view on D’s items¶
-
keys() → a set-like object providing a view on D’s keys¶
-
modify(key: str, /) → Generator[TValue, None, None]¶ Get the current value, and apply changes after it is modified.
-
on_dictionary_update(*, access_token: Optional[str], change: narupa.utilities.change_buffers.DictionaryChange) → None¶ Trigger callbacks based on changes to a shared state dictionary.
- Parameters
access_token – Token used to modify the state.
change – Changes that have occured.
-
on_shared_state_added() → narupatools.core.event.EventListener[narupatools.app.shared_state.OnSharedStateAddedCallback]¶ Callback when a new item is added to the shared state.
-
on_shared_state_changed() → narupatools.core.event.EventListener[narupatools.app.shared_state.OnSharedStateChangedCallback]¶ Callback when an item is modified in the shared state.
-
on_shared_state_removed() → narupatools.core.event.EventListener[narupatools.app.shared_state.OnSharedStateRemovedCallback]¶ Callback when an item is removed from the shared state.
-
set(key: str, snapshot: TValue, /) → narupatools.state.view.reference.SharedStateReference[TValue]¶ Insert a value into the shared state.
-
update(key: str, /, **kwargs: Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]) → narupatools.state.view.reference.SharedStateReference[TValue]¶ Update a value by adding the provided key-value pairs.
This only works if the value supports keyword assignment.
- Parameters
key – Key to modify.
kwargs – Values to add to the value.
-
values() → an object providing a view on D’s values¶
-