createEnhancer

StoreEnhancer<S> createEnhancer<S>(

  1. Store<S> enhance(
    1. Store<S> store
    )
)

Creates an enhancer that wraps the store with additional functionality.

This is a utility for creating custom enhancers without dealing with the full enhancer signature.

Example:

final timestampEnhancer = createEnhancer<AppState>((store) {
  // Return enhanced store with timestamp on each dispatch
  return _TimestampStore(store);
});

Implementation

StoreEnhancer<S> createEnhancer<S>(Store<S> Function(Store<S> store) enhance) =>
    (createStore, reducer, preloadedState) {
      final store = createStore(reducer, preloadedState);
      return enhance(store);
    };