mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Update templates to domain-task 2.0.0. Fixes #166.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fetch } from 'domain-task/fetch';
|
||||
import { fetch, addTask } from 'domain-task';
|
||||
import { typeName, isActionType, Action, Reducer } from 'redux-typed';
|
||||
import { ActionCreator } from './';
|
||||
|
||||
@@ -45,12 +45,13 @@ export const actionCreators = {
|
||||
requestWeatherForecasts: (startDateIndex: number): ActionCreator => (dispatch, getState) => {
|
||||
// Only load data if it's something we don't already have (and are not already loading)
|
||||
if (startDateIndex !== getState().weatherForecasts.startDateIndex) {
|
||||
fetch(`/api/SampleData/WeatherForecasts?startDateIndex=${ startDateIndex }`)
|
||||
let fetchTask = fetch(`/api/SampleData/WeatherForecasts?startDateIndex=${ startDateIndex }`)
|
||||
.then(response => response.json())
|
||||
.then((data: WeatherForecast[]) => {
|
||||
dispatch(new ReceiveWeatherForecasts(startDateIndex, data));
|
||||
});
|
||||
|
||||
addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
|
||||
dispatch(new RequestWeatherForecasts(startDateIndex));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user