SharedStateView

class narupatools.state.view.view.SharedStateView(dictionary: MutableMapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]], /)

Represents a view of a shared state dictionary.

Accessing specific keys will not return their current value, but instead a SharedStateReference to a specific key.

Inheritance

Inheritance diagram of SharedStateView

Methods

__init__

Create a view of a shared state dictionary, exposing the values as references.

clear

Remove all keys in this dictionary.

get

items

keys

modify

Get the current value, and apply changes after it is modified.

set

Insert a value into the shared state.

snapshot

Return a snapshot of each of the current items in this collection.

update

Update a value by adding the provided key-value pairs.

values

__init__(dictionary: MutableMapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]], /)

Create a view of a shared state dictionary, exposing the values as references.

Parameters

dictionary – Shared state dictionary that implements getting, updating and removing keys.

clear()None

Remove all keys in this dictionary.

get(k[, d])D[k] if k in D, else d.  d defaults to None.
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.

set(key: str, snapshot: TValue, /)narupatools.state.view.reference.SharedStateReference[TValue]

Insert a value into the shared state.

snapshot()Dict[str, TValue]

Return a snapshot of each of the current items in this collection.

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