> ## Documentation Index
> Fetch the complete documentation index at: https://abxbus.archivebox.io/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoReturnEventMiddleware

> Emit auto result events for non-None handler returns.

`AutoReturnEventMiddleware` emits `{OriginalEventType}ResultEvent` for successful non-`None` handler return values.

## Constructor params

None.

## Setup with EventBus

> [tab] Python
>
> ```python theme={null}
> from abxbus import EventBus
> from abxbus.middlewares import AutoReturnEventMiddleware
>
> bus = EventBus(
>     name='AppBus',
>     middlewares=[AutoReturnEventMiddleware()],
> )
> ```

> [tab] Rust
>
> ```rust theme={null}
> // Not implemented in the Rust crate yet.
> // Use explicit typed handler wrappers around bus.on(...) for this behavior for now.
> ```

## Behavior

* Runs on completed handler results.
* Emits auto result events only when:
  * handler returned a non-`None` value
  * handler did not error
  * return value is not itself a `BaseEvent`
* Auto event payload uses `data=<handler_return_value>`.
* Skips source events ending in `ErrorEvent` or `ResultEvent`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.