public void Run() { Console.Clear(); Console.WriteLine("Initializing store"); Store.InitializeAsync().Wait(); string input = ""; do { Console.WriteLine("1: Increment counter"); Console.WriteLine("2: Fetch data"); Console.WriteLine("x: Exit"); Console.Write("> "); input = Console.ReadLine(); switch (input.ToLowerInvariant()) { case "1": var incrementCounterActionction = new IncrementCounterAction(); Dispatcher.Dispatch(incrementCounterActionction); break; case "2": var fetchDataAction = new FetchDataAction(); Dispatcher.Dispatch(fetchDataAction); break; case "x": Console.WriteLine("Program terminated"); return; } } while (true); }
public async Task HandleFetchDataAction(FetchDataAction action, IDispatcher dispatcher) { try { var thootles = await _dataService.GetThootlesAsync(); dispatcher.Dispatch(new FetchDataResultAction(thootles)); } catch (Exception e) { dispatcher.Dispatch(new ErrorAction(e.Message)); } }
public async Task HandleAsync(FetchDataAction action, IDispatcher dispatcher) { try { var forecasts = await _httpClient.GetFromJsonAsync <WeatherForecast[]>("WeatherForecast"); dispatcher.Dispatch(new FetchDataSuccessAction(forecasts)); } catch (Exception ex) { dispatcher.Dispatch(new FetchDataErrorAction(ex.Message)); } }
public static WeatherState ReduceFetchDataAction(WeatherState state, FetchDataAction action) { if (state == null) { throw new ArgumentNullException(nameof(state)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } return(new WeatherState( isLoading: true, forecasts: null)); }
public async Task HandleFetchDataAction(FetchDataAction action, IDispatcher dispatcher) { if (action == null) { throw new ArgumentNullException(nameof(action)); } if (dispatcher == null) { throw new ArgumentNullException(nameof(dispatcher)); } var forecasts = await _service.GetForecastAsync(DateTime.Now); //var forecasts = await _http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast"); dispatcher.Dispatch(new FetchDataResultAction(forecasts)); }
public void Run() { Console.Clear(); Console.WriteLine("Initializing store"); Store.InitializeAsync().Wait(); SubscribeToResultAction(); string input = ""; do { Console.WriteLine("1: Increment counter"); Console.WriteLine("2: Fetch data"); Console.WriteLine("3: Get mutable object from API server"); Console.WriteLine("x: Exit"); Console.Write("> "); input = Console.ReadLine(); switch (input.ToLowerInvariant()) { case "1": var action = new IncrementCounterAction(); Dispatcher.Dispatch(action); break; case "2": var fetchDataAction = new FetchDataAction(); Dispatcher.Dispatch(fetchDataAction); break; case "3": var getCustomerAction = new GetCustomerForEditAction(42); Dispatcher.Dispatch(getCustomerAction); break; case "x": Console.WriteLine("Program terminated"); return; } } while (true); }
public async Task HandleFetchDataAction(FetchDataAction action, IDispatcher dispatcher) { var forecasts = await WeatherForecastService.GetForecastAsync(DateTime.Now); dispatcher.Dispatch(new FetchDataResultAction(forecasts)); }
public static WeatherState ReduceFetchDataAction(WeatherState state, FetchDataAction action) => new WeatherState( isLoading: true, forecasts: null);
public async Task HandleFetchDataAction(FetchDataAction action, IDispatcher dispatcher) { var forecasts = await Http.GetFromJsonAsync <WeatherForecast[]>("WeatherForecast"); dispatcher.Dispatch(new FetchDataResultAction(forecasts)); }
public static WeatherState ReduceFetchDataAction(WeatherState state, FetchDataAction action) => new WeatherState(true, null);
public static DataState ReduceFetchDataAction(DataState state, FetchDataAction action) { return(new DataState(state.Thootles, true)); }
public static FetchDataState ReduceFetchDataAction(FetchDataState state, FetchDataAction action) =>