public static ForecastState Reduce(ForecastState state, IAction action) { return(action switch { FetchWeatherForcastDataAction _ => state with { Status = "Loading...", WeatherForecasts = Array.Empty <WeatherForecast>() },
private async Task <WeatherForecast[]> FetchData(FetchWeatherForcastDataAction action) { try { var data = await _httpClient.GetFromJsonAsync <WeatherForecast[]>("WeatherForecast") ?? Array.Empty <WeatherForecast>(); return(data); } catch { return(Array.Empty <WeatherForecast>()); } }