view.py
view.py copied to clipboard
Events
trafficstars
Feature description
view.py should provide an event system to let the user write code for certain app events. The following should at least be supported:
- App Startup
- App Shutdown
- Database Connected (when #10 is ready)
- Request Received
- Exception Occurred
- Route returned non-OK status (client errors or server errors, regardless of whether an exception occurred)
It should also just let the user define their own events to be called at their own will. Perhaps it could also support an auto-locking system to prevent data races?
Feature example API
from view import new_app
app = new_app()
@app.on("startup")
async def startup():
app.fire("my_custom_event")
@app.on("my_custom_event")
async def my_custom_event():
...
Anything else?
No response