Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Update templates to domain-task 2.0.0. Fixes #166.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSandersonMS committed Jul 11, 2016
1 parent fc89747 commit 58bf117
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions samples/react/MusicStore/ReactApp/store/AlbumDetails.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -60,6 +60,7 @@ export const actionCreators = {
}
});

addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
dispatch(new RequestAlbumDetails(albumId));
}
}
Expand Down
5 changes: 3 additions & 2 deletions samples/react/MusicStore/ReactApp/store/FeaturedAlbums.ts
Original file line number Diff line number Diff line change
@@ -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 './';

Expand Down Expand Up @@ -39,10 +39,11 @@ class ReceiveFeaturedAlbums extends Action {
export const actionCreators = {
requestFeaturedAlbums: (): ActionCreator => (dispatch, getState) => {
if (!getState().featuredAlbums.isLoaded) {
fetch('/api/albums/mostPopular')
let fetchTask = fetch('/api/albums/mostPopular')
.then(results => results.json())
.then(albums => dispatch(new ReceiveFeaturedAlbums(albums)));

addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
return dispatch(new RequestFeaturedAlbums());
}
}
Expand Down
5 changes: 3 additions & 2 deletions samples/react/MusicStore/ReactApp/store/GenreDetails.ts
Original file line number Diff line number Diff line change
@@ -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 { Album } from './FeaturedAlbums';
Expand Down Expand Up @@ -39,7 +39,7 @@ export const actionCreators = {
requestGenreDetails: (genreId: number): ActionCreator => (dispatch, getState) => {
// Only load if it's not already loaded (or currently being loaded)
if (genreId !== getState().genreDetails.requestedGenreId) {
fetch(`/api/genres/${ genreId }/albums`)
let fetchTask = fetch(`/api/genres/${ genreId }/albums`)
.then(results => results.json())
.then(albums => {
// Only replace state if it's still the most recent request
Expand All @@ -48,6 +48,7 @@ export const actionCreators = {
}
});

addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
dispatch(new RequestGenreDetails(genreId));
}
}
Expand Down
5 changes: 3 additions & 2 deletions samples/react/MusicStore/ReactApp/store/GenreList.ts
Original file line number Diff line number Diff line change
@@ -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 './';

Expand Down Expand Up @@ -34,9 +34,10 @@ class ReceiveGenresList extends Action {
export const actionCreators = {
requestGenresList: (): ActionCreator => (dispatch, getState) => {
if (!getState().genreList.isLoaded) {
fetch('/api/genres')
let fetchTask = fetch('/api/genres')
.then(results => results.json())
.then(genres => dispatch(new ReceiveGenresList(genres)));
addTask(fetchTask); // Ensure server-side prerendering waits for this to complete
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion samples/react/MusicStore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"aspnet-webpack-react": "^1.0.1",
"bootstrap": "^3.3.6",
"domain-context": "^0.5.1",
"domain-task": "^1.0.0",
"domain-task": "^2.0.0",
"history": "^2.0.0",
"isomorphic-fetch": "^2.2.1",
"memory-fs": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion samples/react/ReactGrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"babel-core": "^6.4.5",
"bootstrap": "^3.3.5",
"domain-task": "^1.0.0",
"domain-task": "^2.0.0",
"formsy-react": "^0.17.0",
"formsy-react-components": "^0.6.3",
"griddle-react": "^0.3.1",
Expand Down
5 changes: 3 additions & 2 deletions templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts
Original file line number Diff line number Diff line change
@@ -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 './';

Expand Down Expand Up @@ -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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/ReactReduxSpa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"aspnet-prerendering": "^1.0.2",
"aspnet-webpack": "^1.0.2",
"babel-core": "^6.5.2",
"domain-task": "^1.0.0",
"domain-task": "^2.0.0",
"react": "^15.0.1",
"react-dom": "^15.0.1",
"react-redux": "^4.4.4",
Expand Down
2 changes: 1 addition & 1 deletion templates/yeoman/src/generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-aspnetcore-spa",
"version": "0.2.1",
"version": "0.2.2",
"description": "Single-Page App templates for ASP.NET Core",
"author": "Microsoft",
"license": "Apache-2.0",
Expand Down

0 comments on commit 58bf117

Please sign in to comment.