add, remove now accept iterables

update README

patch bump
This commit is contained in:
onyx-and-iris 2022-10-06 18:07:34 +01:00
parent ad69d2cf14
commit 816fd76213
3 changed files with 26 additions and 5 deletions

View File

@ -629,6 +629,20 @@ example:
vm.event.ldirty = True vm.event.ldirty = True
vm.event.pdirty = False vm.event.pdirty = False
```
Or add, remove a list of events.
The following methods are available:
- `add()`
- `remove()`
- `get()`
example:
```python
vm.event.remove(["pdirty", "mdirty", "midi"])
# get a list of currently subscribed # get a list of currently subscribed
print(vm.event.get()) print(vm.event.get())

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "voicemeeter-api" name = "voicemeeter-api"
version = "0.8.3" version = "0.8.4"
description = "A Python wrapper for the Voiceemeter API" description = "A Python wrapper for the Voiceemeter API"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -1,4 +1,5 @@
import logging import logging
from typing import Iterable, Union
class Event: class Event:
@ -59,8 +60,14 @@ class Event:
def any(self) -> bool: def any(self) -> bool:
return any(self.subs.values()) return any(self.subs.values())
def add(self, event): def add(self, events: Union[str, Iterable[str]]):
setattr(self, event, True) if isinstance(events, str):
events = [events]
for event in events:
setattr(self, event, True)
def remove(self, event): def remove(self, events: Union[str, Iterable[str]]):
setattr(self, event, False) if isinstance(events, str):
events = [events]
for event in events:
setattr(self, event, False)