view.py icon indicating copy to clipboard operation
view.py copied to clipboard

Events

Open ZeroIntensity opened this issue 2 years ago • 0 comments
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

ZeroIntensity avatar Nov 06 '23 18:11 ZeroIntensity