Builtin Model Types¶
Spectate provides a number of builtin model types that you can use out of the box. For most users these built-in types should be enough, however if you’re adventurous, then you can create your own Custom Models.
Dictionary¶
The Dict
model is a subclass of Python’s standard
dict
. This will produce events when the value of a key in the dictionary
changes or is deleted. This will result when calling methods like dict.update()
and dict.pop()
, but also when using the normal syntax to set or delete an item.
Events produced by Dict
have the following fields:
Field |
Description |
---|---|
|
The key in the dict model that changed. |
|
|
|
|
List¶
The List
model is a subclass of Python’s standard
list
. This model will produce events when an element of the list changes
or an element changes from one position to another. This may happen when calling
methods like list.append()
or list.remove()
, but also when using the
normal syntax to set or delete an item. Events produced by
List
have the following keys:
Field |
Description |
---|---|
|
The index in the dict model that changed. |
|
|
|
|
Set¶
The Set
model is a subclass of Python’s standard
set
. This model will produce events when an element of the set changes.
This may happen when calling methods like set.add()
or set.discard()
.
Events produced by Set
have the following keys:
Field |
Description |
---|---|
|
A set of values that were removed due to the change. |
|
A set of the values that were added due to the change. |
Object¶
The Object
model is a subclass of Python’s standard
object
. This model will produce events when an attribute of the object changes
or is deleted. This may happen when using setattr()
or delattr()
, but also
when using the normal syntax to set or delete attributes. Events produced by
Object
have the following keys:
Field |
Description |
---|---|
|
The attribute in the model that changed. |
|
|
|
|