enhancer

StoreEnhancer<S> get enhancer

The store enhancer function.

Implementation

StoreEnhancer<S> get enhancer => (createStore, reducer, preloadedState) {
  S wrappedReducer(S state, Action action) {
    if (_isTimeTraveling) return state;

final nextState = reducer(state, action);

// Record state in history if (_currentIndex < _history.length - 1) { // We've time traveled and are now making new changes // Truncate future history _history.removeRange(_currentIndex + 1, _history.length); } _history.add(nextState); _currentIndex = _history.length - 1;

return nextState; }

_store = createStore(wrappedReducer, preloadedState); _history.add(preloadedState); _currentIndex = 0;

return _TimeTravelStore(this, _store!); };