mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 10:30:48 +00:00
add property setters in event class
use event property setters in examples update README patch bump
This commit is contained in:
parent
243a43ac22
commit
0c60fe3d5e
20
README.md
20
README.md
@ -302,20 +302,30 @@ The following methods are available:
|
||||
example:
|
||||
|
||||
```python
|
||||
# register the app self as an event observer
|
||||
self.vban.subject.add(self)
|
||||
# register an app to receive updates
|
||||
class App():
|
||||
def __init__(self, vban):
|
||||
vban.subject.add(self)
|
||||
...
|
||||
```
|
||||
|
||||
#### `vban.event`
|
||||
|
||||
You may also add/remove event subscriptions as necessary with the Event class.
|
||||
Use the event class to toggle updates as necessary.
|
||||
|
||||
The following properties are available:
|
||||
|
||||
- `pdirty`: boolean
|
||||
- `mdirty`: boolean
|
||||
- `midi`: boolean
|
||||
- `ldirty`: boolean
|
||||
|
||||
example:
|
||||
|
||||
```python
|
||||
vban.event.add("ldirty")
|
||||
vban.event.ldirty = True
|
||||
|
||||
vban.event.remove("pdirty")
|
||||
vban.event.pdirty = False
|
||||
|
||||
# get a list of currently subscribed
|
||||
print(vban.event.get())
|
||||
|
@ -8,8 +8,8 @@ class Observer:
|
||||
self.vban = vban
|
||||
# register your app as event observer
|
||||
self.vban.subject.add(self)
|
||||
# add level updates, since they are disabled by default.
|
||||
self.vban.event.add("ldirty")
|
||||
# enable level updates, since they are disabled by default.
|
||||
self.vban.event.ldirty = True
|
||||
|
||||
# define an 'on_update' callback function to receive event updates
|
||||
def on_update(self, subject):
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "vban-cmd"
|
||||
version = "1.5.4"
|
||||
version = "1.5.5"
|
||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||
license = "MIT"
|
||||
|
@ -18,13 +18,23 @@ class Event:
|
||||
self.logger.info(", ".join(info))
|
||||
|
||||
@property
|
||||
def pdirty(self):
|
||||
def pdirty(self) -> bool:
|
||||
return self.subs["pdirty"]
|
||||
|
||||
@pdirty.setter
|
||||
def pdirty(self, val: bool):
|
||||
self.subs["pdirty"] = val
|
||||
self.info(f"pdirty {'added to' if val else {'removed from'}}")
|
||||
|
||||
@property
|
||||
def ldirty(self):
|
||||
def ldirty(self) -> bool:
|
||||
return self.subs["ldirty"]
|
||||
|
||||
@ldirty.setter
|
||||
def ldirty(self, val: bool):
|
||||
self.subs["ldirty"] = val
|
||||
self.info(f"ldirty {'added to' if val else {'removed from'}}")
|
||||
|
||||
def get(self) -> list:
|
||||
return [k for k, v in self.subs.items() if v]
|
||||
|
||||
@ -32,9 +42,7 @@ class Event:
|
||||
return any(self.subs.values())
|
||||
|
||||
def add(self, event):
|
||||
self.subs[event] = True
|
||||
self.info(f"{event} added to")
|
||||
setattr(self, event, True)
|
||||
|
||||
def remove(self, event):
|
||||
self.subs[event] = False
|
||||
self.info(f"{event} removed from")
|
||||
setattr(self, event, False)
|
||||
|
Loading…
Reference in New Issue
Block a user