Exemple #1
0
        public async Task <string> Dispatch(IAction action)
        {
            string msg = string.Empty;

            IActionReducer reducer = GetReducer(action);

            msg = await reducer.Reduce(action);

            return(msg);
        }
Exemple #2
0
        private IActionReducer GetReducer(IAction action)
        {
            IActionReducer retReducer = null;

            if (Reducers.Keys.Contains(action.Type))
            {
                retReducer = Reducers[action.Type];
            }

            return(retReducer);
        }
Exemple #3
0
 public RootReducerBuilder <TState> UseReducer(IActionReducer <TState> reducer)
 {
     _reducers.Add(reducer);
     return(this);
 }
Exemple #4
0
 public IObservable <TState> Scan <TState>(TState initialState, IActionReducer <TState> reducer)
 {
     return(_actions.Scan(initialState, reducer.Reduce));
 }
Exemple #5
0
 public Store(IActionReducer <TState> rootReducer, IActionDispatcher dispatcher, TState initialState = default(TState))
 {
     _dispatcher = dispatcher;
     _state      = new BehaviorSubject <TState>(initialState);
     _dispatcher.Scan(initialState, rootReducer).Subscribe(s => _state.OnNext(s));
 }