void DispatchLocation(NewLocationAction locationAction) { var locationReducer = _options.LocationReducer; if (locationReducer == null && locationAction is TAction) { // Just use the RootReducer unless the user has configured a LocationReducer var genericAction = (TAction)(object)locationAction; Dispatch(genericAction); } if (locationReducer == null) { return; } lock (_syncRoot) { State = locationReducer(State, locationAction); Task.Run(async() => await DevToolsInterop.Log(locationAction.ToString(), _options.StateSerializer(State))); History.Add(new HistoricEntry <TState, object>(State, locationAction)); } OnChange(null); }
public void Dispatch(TAction action) { lock (_syncRoot) { State = _rootReducer(State, action); DevToolsInterop.Log(action.ToString(), _options.StateSerializer(State)); History.Add(new HistoricEntry <TState, object>(State, action)); } OnChange(null); }
LocationAction Dispatch(LocationAction action) { lock (_syncRoot) { State = _locationReducer(State, action); DevToolsInterop.Log(action.ToString(), JsonUtil.Serialize(State)); History.Add(new HistoricEntry <TState, object>(State, action)); } OnChange(null); return(action); }
public Store(TState initialState, Reducer <TState, TAction> rootReducer, ReduxOptions <TState> options, IJSRuntime jsRuntime) { _initialState = initialState; _rootReducer = rootReducer; _options = options; State = initialState; DevToolsInterop.JSRuntime = jsRuntime; DevToolsInterop.Reset += OnDevToolsReset; DevToolsInterop.TimeTravel += OnDevToolsTimeTravel; DevToolsInterop.Log("initial", _options.StateSerializer(State)); History = new List <HistoricEntry <TState, object> > { new HistoricEntry <TState, object>(State) }; }
public Store( Reducer <TState, TAction> mainReducer, Reducer <TState, LocationAction> locationReducer, Func <TState, string> getLocation, TState initialState = default(TState)) { _mainReducer = mainReducer; _locationReducer = locationReducer; _getLocation = getLocation; _initialState = initialState; State = initialState; DevToolsInterop.Reset += OnDevToolsReset; DevToolsInterop.TimeTravel += OnDevToolsTimeTravel; DevToolsInterop.Log("initial", JsonUtil.Serialize(State)); History = new List <HistoricEntry <TState, object> > { new HistoricEntry <TState, object>(State) }; }