Describe the Enhancement you want
register_lifespan_task doesn't return the argument it gets, so if used as a decorator, the decorated task function name gets bound to None and thus cannot be called directly by other parts of the code.
- What is the benefit of the enhancement?
Cleaner code, more predictable behavior, more convenient.
- Show an example/usecase were the improvement are needed.
app = rx.App()
@app.register_lifespan_task
def polling_task(app: Starlette):
...
@app.register_lifespan_task(timeout=10)
def check_for_updates(timeout: int):
...
For the second construction to work, the register_lifespan_task needs to act more like a decorator and have an internal wrapper function which can be returned directly as a partial if the user provides other args besides the function itself.
Describe the Enhancement you want
register_lifespan_task doesn't return the argument it gets, so if used as a decorator, the decorated task function name gets bound to
Noneand thus cannot be called directly by other parts of the code.Cleaner code, more predictable behavior, more convenient.
For the second construction to work, the
register_lifespan_taskneeds to act more like a decorator and have an internal wrapper function which can be returned directly as a partial if the user provides other args besides the function itself.