Skip to content

Commit

Permalink
docs: add app to events usage example (#2191)
Browse files Browse the repository at this point in the history
* Fix events usage example

Add the `app` definition so that the example is provides all the information needed to make a functional example.

* docs: add `app` to events usage example

fixed linting error failing the CI checks

* docs: add `app` to events usage example

Spacing Linting issue

* fix: format correction

---------
  • Loading branch information
juan-riveros authored Aug 22, 2023
1 parent 1362a8b commit aede6b9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/usage/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Litestar supports a simple implementation of the event emitter / listener patter
from litestar import Request, post
from litestar.events import listener
from litestar import Litestar
from db import user_repository
from utils.email import send_welcome_mail
Expand Down Expand Up @@ -39,6 +40,9 @@ Litestar supports a simple implementation of the event emitter / listener patter
request.app.emit("user_created", email=data.email)
app = Litestar(
route_handlers=[create_user_handler], listeners=[send_welcome_email_handler]
)
The above example illustrates the power of this pattern - it allows us to perform async operations without blocking,
Expand Down

0 comments on commit aede6b9

Please sign in to comment.