Middleware

A generic interface representing a middleware component that can be attached and detached.

Middleware components provide functionality that can be dynamically activated or deactivated, often handling background tasks, event listeners, or lifecycle-dependent operations.

Parameters

C

The type of MiddlewareContext that this middleware interacts with.

Inheritors

Functions

Link copied to clipboard
abstract fun onAttached(middlewareContext: C)

Invoked when the middleware is active. Use this method to initialize or set functionality like coroutine scopes, listeners, etc.

Link copied to clipboard
abstract fun onDetached(middlewareContext: C)

Invoked when the middleware is no longer active. Use this method to cleanup or release resources that were initialized or used during the active period. No further calls to the middleware will be made after this method is invoked, but the object can become active after another onAttached call.