async def _postprocess(
        self, state: BaseState, event: Event, update: StateUpdate
    ) -> StateUpdate:
        """Postprocess the event.

        This is where middleware can modify the delta after it is processed.
        Each middleware is called in the order it was added to the app.

        Args:
            state: The state to postprocess.
            event: The event to postprocess.
            update: The current state update.

        Returns:
            The state update to return.
        """
        out = update
        for middleware in self._middlewares:
            out = middleware.postprocess(
                app=self,  # pyright: ignore [reportArgumentType]
                state=state,
                event=event,
                update=update,
            )
            if inspect.isawaitable(out):
                out = await out
        return out  # pyright: ignore[reportReturnType]
Postprocess the event.

        This is where middleware can modify the delta after it is processed.
        Each middleware is called in the order it was added to the app.

        Args:
            state: The state to postprocess.
            event: The event to postprocess.
            update: The current state update.

        Returns:
            The state update to return.
        
reflex/app_mixins/middleware.py