ZeroIntensity / view.py

The Batteries-Detachable Web Framework
https://view.zintensity.dev
MIT License
206 stars 15 forks source link

Events #79

Open ZeroIntensity opened 8 months ago

ZeroIntensity commented 8 months ago

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:

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