state

class trame_server.state.State(server)

Flexible dictionary managing a server shared state. Variables can be accessed with either the [] or . notation.

client_only(*_args)

Tag a given set of variable name(s) to be client only. This means that when they get changed on the client side, the server will not be aware of their change and no network bandwidth will be used to maintain the server in sync with the client state.

Parameters:

*_args

A list a variable name

to_dict()

Flush current state modification and return the resulting state state as a python dict.

has(key)

Check is a key is currently available in the state

setdefault(key, value)

Set an initial value if the key is not present yet

is_dirty(*_args)

Check if any provided key name(s) still has a pending changed that will need to be flushed.

is_dirty_all(*_args)

Check if all provided key name(s) has a pending changed that will need to be flushed.

dirty(*_args)

Mark existing variable name(s) to be modified in a way that they will be pushed again at flush time.

clean(*_args)

Save pending variable(s) and unmark them as dirty. This will prevent change listener(s) to react or the client to be aware of any change.

update(_dict)

Update the current state dict with the provided one

flush()

Force pushing modified state and execute any @state.change listener

property change

Function decorator for registering state change executions

property initial

Return the initial state without triggering a flush