Skip to main content

Module middleware

Module middleware 

Source
Expand description

Middleware which can be wrapped around the Core to modify its behaviour.

Note that this is still somewhat experimental.

This is useful for changing the mechanics of the Core without modifying the actual behaviour of the app.

Currently, the main use-case is processing effects requested by the app inside the core, but outside the app itself (which is side-effect free and synchronous). To do this, use Layer::handle_effects_using and provide an implementation of EffectMiddleware.

Note that apps using middleware must be Send and Sync, because the effect middlewares are expected to process effects asynchronously (in order not to block the caller of process_event). On native targets this typically means a background thread; on WASM it means an async task (e.g. spawn_local). See EffectMiddleware for more discussion.

Note: In the documentation we refer to the directions in the middleware chain as “down” - towards the core, and “up” - away from the Core, towards the Shell.

Re-exports§

pub use crate::bridge::BincodeFfiFormat;
pub use crate::bridge::FfiFormat;
pub use crate::bridge::JsonFfiFormat;

Structs§

Bridge
FFI Bridge with support for wrapping a middleware stack
EffectResolver
HandleEffectLayer
Middleware layer able to process some of the effects. This implements the general behaviour making sure all follow-up effects are processed and routed to the right place and delegates to the generic parameter EM, which implements EffectMiddleware.
MapEffectLayer
Middleware for converting the effect type to another type.

Traits§

EffectMiddleware
An effect processing middleware.
Layer
A layer in the middleware stack.