Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: allow dispatch to take a Callable which generates the payload #62

Open
judahrand opened this issue Jun 18, 2024 · 0 comments

Comments

@judahrand
Copy link

judahrand commented Jun 18, 2024

Sometimes generating the payload of an event might involve some serialization overhead which would be better deferred until after the response has been sent. An example of this might be converting a numpy array to a type which is compatible with json.dumps.

I'm imagining something like:

@app.route("/")
async def root(request: Request) -> JSONResponse:
    arr = np.random.random(512)
    dispatch("new event", payload=lambda: {'arr': arr.tolist()})
    return JSONResponse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant