docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Delegate Middleware<TStoreState>

    A Redux middleware is a higher-order function that composes a dispatch function to return a new dispatch function.

    Namespace: Unity.AppUI.Redux
    Assembly: Unity.AppUI.Redux.dll
    Syntax
    public delegate DispatcherComposer Middleware<TStoreState>(IStore<TStoreState> store)
    Parameters
    Type Name Description
    IStore<TStoreState> store

    The store.

    Returns
    Type Description
    DispatcherComposer

    The dispatcher composer.

    Type Parameters
    Name Description
    TStoreState

    The type of the store state.

    Examples

    The following example shows how to create a middleware that logs all actions.

    // Middleware that logs all actions
    var loggerMiddleware = (store) => next => action =>
    {
       Debug.Log($"Dispatching action: {action}");
       // Call the next middleware in the chain
       next(action);
    };
    // Apply the middleware to the store
    var middlewares = Store.ApplyMiddlewares(loggerMiddleware);
    var enhancer = Store.ComposeEnhancers(middlewares, DefaultEnhancer.GetDefaultEnhancer());
    var store = Store.CreateStore(reducer, initialState, enhancer);

    See Also

    ApplyMiddleware<TState>(params Middleware<TState>[])
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)