docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Delegate StoreEnhancer<TState>

    A function to enhance the store creation.

    Namespace: Unity.AppUI.Redux
    Assembly: Unity.AppUI.Redux.dll
    Syntax
    public delegate StoreEnhancerStoreCreator<TState> StoreEnhancer<TState>(StoreEnhancerStoreCreator<TState> createStore)
    Parameters
    Type Name Description
    StoreEnhancerStoreCreator<TState> createStore

    The store creation function.

    Returns
    Type Description
    StoreEnhancerStoreCreator<TState>

    The enhanced store creation function.

    Type Parameters
    Name Description
    TState

    The type of the store state.

    Examples

    The following example shows how to enhance the store creation to replace the dispatcher with a custom dispatcher.

    // Enhancer that logs the action and the state before and after the action.
    var enhancer = (createStore) => (reducer, initialState) =>
    {
        var store = createStore(reducer, initialState);
        var originalDispatcher = store.dispatcher;
        store.dispatcher = new Dispatcher(action =>
        {
            Debug.Log($"Dispatching action: {action}");
            originalDispatcher(action);
            Debug.Log($"State after action: {store.GetState()}");
        });
        return store;
    };
    // You can compose enhancers using Store.ComposeEnhancers
    var composedEnhancer = Store.ComposeEnhancers(enhancer, DefaultEnhancer.GetDefaultEnhancer());
    // Create the store with one enhancer or a composed enhancer
    var store = Store.CreateStore(reducer, initialState, composedEnhancer);
    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)