Skip to content

Commit 9bd84a0

Browse files
committed
Update README.md documentation to reflect change in how Event models are defined
1 parent 3a69a87 commit 9bd84a0

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ The SDK allows you to create custom event listeners and events by extending the
292292
293293
To create a custom event listener:
294294
295-
1. Create new event model that inherits from `EventBase`.
295+
1. Create new event model that inherits from `EventBase["eventName"]`.
296296
2. Create a new class that inherits from `EventListener`.
297297
a. Implement the required `listen` and `stop` methods. The `listen` method should yield results as a json string that matches the new event model.
298298
b. List the new event classes in the `event_models` class variable of the new `EventListener` class.
@@ -307,11 +307,15 @@ from streamdeck.event_listener import EventListener
307307
from streamdeck.models.events import EventBase
308308
309309
310-
class MyCustomEvent(EventBase):
311-
event: Literal["somethingHappened"]
312-
... # Define additional data attributes here
310+
class MyCustomEvent(EventBase["somethingHappened"]):
311+
# The 'event' field's type annotation is internally set as Literal["somethingHappened"]
312+
# Define additional data attributes here
313+
result: str
314+
313315

314316
class MyCustomEventListener(EventListener):
317+
event_models = [MyCustomEvent]
318+
315319
def listen(self) -> Generator[str | bytes, None, None]:
316320
...
317321
# Listen/poll for something here in a loop, and yield the result.
@@ -320,7 +324,7 @@ class MyCustomEventListener(EventListener):
320324
# while self._running is True:
321325
# result = module.check_status()
322326
# if result is not None:
323-
# yield json.dumps({"event": "somethingHappend", "result": result})
327+
# yield json.dumps({"event": "somethingHappened", "result": result})
324328
# time.sleep(1)
325329

326330
def stop(self) -> None:
@@ -344,7 +348,7 @@ To use your custom event listener, add it to your `pyproject.toml` file:
344348
]
345349
```
346350
347-
The `event_listeners` list should contain strings in module format for each module you want to use.
351+
The `event_listener_modules` list should contain strings in module format for each module you want to use.
348352
349353
350354
## Creating and Packaging Plugins

0 commit comments

Comments
 (0)