mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +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 './';
|
||||
import { Genre } from './GenreList';
|
||||
@@ -51,7 +51,7 @@ export const actionCreators = {
|
||||
requestAlbumDetails: (albumId: number): ActionCreator => (dispatch, getState) => {
|
||||
// Only load if it's not already loaded (or currently being loaded)
|
||||
if (albumId !== getState().albumDetails.requestedAlbumId) {
|
||||
fetch(`/api/albums/${ albumId }`)
|
||||
let fetchTask = fetch(`/api/albums/${ albumId }`)
|
||||
.then(results => results.json())
|
||||
.then(album => {
|
||||
// Only replace state if it's still the most recent request
|
||||
@@ -60,6 +60,7 @@ export const actionCreators = {
|
||||
}
|
||||
});
|
||||
|
||||
addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
|
||||
dispatch(new RequestAlbumDetails(albumId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user