Describe the bug
Starlette is an implementation detail, reflex might use a different ASGI framework down the road, so all interfaces that reflex exposes should be wrappers or framework objects to prevent implementation details from leaking out into the world.
Also, the docs say the lifespan function gets a FastAPI instance, which is just wrong, since the framework moved away from FastAPI... see, this is exactly what I mean.
To Reproduce
Any lifespan task that takes an app argument gets passed a Starlette instance.
Expected behavior
The task should get the reflex App, and from there can get the Starlette instance if needed.
Specifics (please complete the following information):
- Python Version: any
- Reflex Version: >=0.5.2
- OS: any
Additional context
This is a BREAKING CHANGE 😔. So we need to be careful about bringing it in.
Suggested strategy -- check the lifespan function annotation:
- If the
app arg is annotated as rx.App, then pass the reflex app instance. This is the new happy case.
- Otherwise, maintain the old behavior with a deprecation warning along the lines of "in 1.0,
rx.App will be passed for app. Opt-in to the new behavior by annotating app as rx.App."
Describe the bug
Starlette is an implementation detail, reflex might use a different ASGI framework down the road, so all interfaces that reflex exposes should be wrappers or framework objects to prevent implementation details from leaking out into the world.
Also, the docs say the lifespan function gets a
FastAPIinstance, which is just wrong, since the framework moved away from FastAPI... see, this is exactly what I mean.To Reproduce
Any lifespan task that takes an
appargument gets passed a Starlette instance.Expected behavior
The task should get the reflex App, and from there can get the Starlette instance if needed.
Specifics (please complete the following information):
Additional context
This is a BREAKING CHANGE 😔. So we need to be careful about bringing it in.
Suggested strategy -- check the lifespan function annotation:
apparg is annotated asrx.App, then pass the reflex app instance. This is the new happy case.rx.Appwill be passed forapp. Opt-in to the new behavior by annotatingappasrx.App."