示例#1
0
        public void Dispatch(IRealmAction action)
        {
            TState localState = _dispatch(action);

            if (localState != null)
            {
                State = localState;
                OnChange(null);
            }
        }
示例#2
0
 public static AppState RootReducer(AppState appState, IRealmAction action)
 {
     if (appState == null)
     {
         throw new ArgumentNullException(nameof(appState));
     }
     return(new AppState
     {
         Count = CounterReducer(appState.Count, action)
     });
 }
示例#3
0
        public static bool IsLoadingReducer(bool isLoading, IRealmAction action)
        {
            switch (action)
            {
            case Actions.IsLoading.Set a:
                return(a.Value);

            default:
                return(isLoading);
            }
        }
 public TState Invoke(IRealmAction action)
 {
     if (action is IAsyncRealmAction)
     {
         action.GetType().GetMethod("Invoke").Invoke(action, null);
         return(default(TState));
     }
     else
     {
         return(_next(action));
     }
 }
示例#5
0
        public static AppState RootReducer(AppState appState, IRealmAction action)
        {
            if (appState == null)
            {
                throw new ArgumentNullException(nameof(appState));
            }

            return(new AppState
            {
                IsLoading = IsLoadingReducer(appState.IsLoading, action),
                Count = CounterReducer(appState.Count, action),
                WeatherForecasts = WeatherForecastsReducer(appState.WeatherForecasts, action)
            });
        }
示例#6
0
        public static int CounterReducer(int count, IRealmAction action)
        {
            switch (action)
            {
            case Actions.Counter.IncrementByValue a:
                return(count + a.Value);

            case Actions.Counter.DecrementByValue a:
                return(count - a.Value);

            case Actions.Counter.Dispose _:
            case Actions.Counter.Reset _:
                return(0);

            default:
                return(count);
            }
        }
示例#7
0
        public TState Invoke(IRealmAction action)
        {
            if (!Configured)
            {
                Configured = true;
            }
            switch (action)
            {
            case RealmReduxDevToolsAppState <TState> a:
                return(a.State);

            default:
                TState nextState = Next(action);
                if (nextState != null && Array.IndexOf(ActionsToIgnore, action.GetType()) == -1)
                {
                    History.Add(new Tuple <string, string>(UriHelper.Uri, JsonSerializer.Serialize <TState>(nextState)));
                    reduxDevToolsInterop.Send(action, nextState);
                }
                return(nextState);
            }
        }
示例#8
0
        internal TState InitialDispatch(IRealmAction action)
        {
            TState localState = _rootReducer(State, action);

            return(localState);
        }
示例#9
0
        public static IEnumerable <WeatherForecast> WeatherForecastsReducer(IEnumerable <WeatherForecast> weatherForecasts, IRealmAction action)
        {
            switch (action)
            {
            case Actions.WeatherForecasts.Set a:
                return(a.Value);

            case Actions.WeatherForecasts.Clear _:
                return(new List <WeatherForecast>());

            default:
                return(weatherForecasts);
            }
        }