@@ -8,33 +8,33 @@ demo into a [TypeScript](http://www.typescriptlang.org/), [React](http://faceboo
88
99> Live Demo: http://react-chat.servicestack.net
1010
11+ ## React App VS.NET Template
12+
1113React Chat was developed using
1214[ ServiceStackVS's] ( https://github.com/ServiceStack/ServiceStackVS ) npm-based ** React App**
13- VS.NET SPA Template providing a productive integrated client / server solution for building modern
14- complex JavaScript Single Page Apps in VS.NET that includes today's best-of-class components:
15+ VS.NET SPA Template providing a productive integrated solution for building modern complex JavaScript
16+ Single Page Apps in VS.NET that includes the following best-of-class components:
1517
1618 - [ TypeScript] ( http://www.typescriptlang.org/ ) - Superset of JavaScript with optional typing, advanced language features and down-level ES5 support
1719 - [ JSPM] ( http://jspm.io/ ) - JavaScript Package Manager supporting SystemJS modules and multiple npm and GitHub repositories
1820 - [ typings] ( https://github.com/typings/typings ) - Package manager to search and install TypeScript definition files
1921 - [ React] ( https://facebook.github.io/react/ ) - Simple, high-performance JavaScript UI Framework utilizing a Virtual DOM and Reactive Data flows
2022
21- Whilst the pre-configured [ Gulp] ( http://gulpjs.com/ ) scripts provides Client and Server automation of
22- packaging, bundling, minifying and deployments via MS WebDeploy encompassing a productive base for the
23- development of large-scale, JavaScript Apps that's further enhanced by a great development experience
24- within Visual Studio.
23+ Whilst the pre-configured [ Gulp] ( http://gulpjs.com/ ) scripts provides automation scripts for Client and Server
24+ packaging, bundling, minifying and deployments via MS WebDeploy.
2525
2626## [ TypeScript Redux] ( https://github.com/ServiceStackApps/typescript-redux )
2727
2828React Chat also uses [ Redux] ( https://github.com/reactjs/redux ) - the most popular Flux-like library
2929for maintaining Application state in React Apps. If you're new to any of these technologies we recommend going
3030through our in-depth [ TypeScript, React + Redux step-by-step Guide] ( https://github.com/ServiceStackApps/typescript-redux )
31- which walks you through from building a Hello World TypeScript React project from scratch to building a more
32- complex network-connected Server Events App.
31+ which walks you through from building the simplest Hello World TypeScript React project to a more complex
32+ real-time networked Server Events App.
3333
3434## Pre-requisites
3535
36- If you haven't yet, install [ ServiceStackVS VS.NET extension] ( https://github.com/ServiceStack/ServiceStack/wiki/Creating-your-first-project#step-1-download-and-install-servicestackvs ) .
37- You'll also need to [ install TypeScript for VS.NET] ( http://www.typescriptlang.org/#download-links ) .
36+ If you haven't installed it yet, you'll need [ ServiceStackVS VS.NET extension] ( https://github.com/ServiceStack/ServiceStack/wiki/Creating-your-first-project#step-1-download-and-install-servicestackvs ) .
37+ as well as [ TypeScript for VS.NET] ( http://www.typescriptlang.org/#download-links ) .
3838
3939## Getting Started
4040
@@ -43,45 +43,44 @@ To create a Single Page React Apps with ServiceStack choose the **React App** VS
4343![ ] ( https://raw.githubusercontent.com/ServiceStack/Assets/master/img/livedemos/chat-react/ssvs-proj-template.png )
4444
4545This can take up to a few minutes to fetch all the javascript packages from npm. You can watch the ** Output**
46- window to view the progress.
46+ window to view the progress:
4747
4848![ ] ( https://raw.githubusercontent.com/ServiceStackApps/typescript-react-template/master/img/ServiceStackVS-npm-output.png )
4949
50- Once it's completed you can run hit ** F5** to run the App and see a working
51- client/server Hello World React App:
50+ Once completed, hit ** F5** to run the App and see a working client/server Hello World React App:
5251
5352![ ] ( https://raw.githubusercontent.com/ServiceStackApps/typescript-react-template/master/img/default-app.png )
5453
5554## Optimal Development and Deployment workflow
5655
5756Fast dev iterations are one of the immediate productivity benefits when developing JavaScript Apps. By using
58- TypeScript we sacrifice a bit of the immediacy as we're no longer developing the JavaScript source files
59- the browsers will run directly but with VS.NET's TypeScript support we can get pretty close which will
60- generate the corresponding ` .js ` source files each time we save a TypeScript ` .ts ` source file.
57+ TypeScript we sacrifice a bit of the immediacy as we're no longer editing the JavaScript source files directly
58+ that the browsers will run, but VS.NET's TypeScript support gets us pretty close as it will generate the
59+ corresponding ` .js ` each time we save its original TypeScript ` .ts ` source file.
6160
62- Much of the time the development experience with TypeScript is seamless as by the time we modify our source
63- files in VS.NET and hit ** Ctrl+S ** to save our TypeScript source files and switch over to our browser
64- the ` .js ` files are already generated and by the time we reload our app. Although you'll want to keep an
65- eye on the ** Error List ** VS.NET Tab for any TypeScript compiler errors as they'll indicate any remaining
66- errors you need to fix before TypeScript is able to generate the ` .js ` files.
61+ A lot of the time the development experience with TypeScript is seamless as by the time we hit ** Ctrl+S **
62+ to save our modified TypeScript source files and switch over to our browser the ` .js ` files are already
63+ generated by the time we reload our app. Although you'll want to keep an eye on the ** Error List ** VS.NET Tab
64+ for any TypeScript compiler errors as they'll indicate any remaining errors you'll need to fix in order for
65+ TypeScript to generate the ` .js ` files.
6766
6867This is the typical workflow during development where you'll mostly just be editing TypeScript ` .ts ` files
69- under ` src/ ` and switching to the browser to view your changes. You won't need to run any of the Gulp tasks
70- during development as they're primarily for staging and packaging your App for production so it's ready for
71- deployment.
68+ under ` src/ ` folder and switching to the browser to view your changes. You won't need to run any of the Gulp
69+ tasks during development as they're primarily for staging and packaging your App for production so it's
70+ ready for deployment.
7271
7372## Installing additional libraries
7473
7574Having an npm-based VS.NET Template gives us access to the largest repository of JavaScript libraries available.
76- For front-end dependencies we'll be using [ JSPM] ( http://jspm.io/ ) to fetch all our non-default packages for
75+ For front-end dependencies we'll be using [ JSPM] ( http://jspm.io/ ) to fetch all our additional JS packages for
7776us.
7877
7978The easiest way to use JSPM is via the console which you can do by holding down ** Shift** whilst
80- right-clicking the ** ReactChat** Host project folder to bring up a console at that directory:
79+ right-clicking the ** ReactChat** Host project folder to open a new console at that directory:
8180
8281![ ] ( https://raw.githubusercontent.com/ServiceStack/Assets/master/img/livedemos/chat-react/open-console.png )
8382
84- When the console is open we can get jspm to fetch our dependencies for us, we'll first need ** redux** :
83+ With the console open, we can get jspm to fetch our dependencies for us. Chat just needs ** redux** :
8584
8685 c:\proj> jspm install redux
8786
@@ -92,7 +91,7 @@ And Redux's bindings to React, **react-redux**:
9291The list of dependencies are maintained in jspm's ` config.js ` with the libraries themselves stored under
9392` jspm_packages/ ` folder.
9493
95- Since we're using TypeScript we'll also need the ambient Type Definitions of both libraries:
94+ Since we're using TypeScript we'll also need the ambient Type Definitions for both libraries:
9695
9796 c:\proj> typings install redux --ambient --save
9897
@@ -110,25 +109,10 @@ files, e.g:
110109
111110### Updating deps.lib.js cache
112111
113- It's recommended after installing new packages to modify ` src/deps.tsx ` to add
114- reference to the new packages then rerun the ** 00-update-deps-js** Gulp task which will generate a cache
115- of dependencies in ` deps.lib.js ` which will minimize the number of requests and allow for faster developer
116- iteration times.
117-
118- ### .gitignore
119-
120- Similar to how we ignore NuGet ` packages/ ` folder in ** .gitignore** to avoid checking them into our Git
121- repository, we'll want to do the same for npm, jspm and typing folders as well. We also don't need to
122- check in the staging ` wwwroot/ ` folder or the ` webdeploy.zip ` MS WebDeploy package that our Gulp script
123- generates for us, which we can all ignore by adding them to Git repositories ** .gitignore** :
124-
125- ```
126- node_modules/
127- jspm_packages/
128- typings/
129- wwwroot/
130- webdeploy.zip
131- ```
112+ It's recommended after installing new packages to modify ` src/deps.tsx ` to add reference to the new modules
113+ then rerun the ** 00-update-deps-js** Gulp task to generate a cache of the referenced dependencies in
114+ ` deps.lib.js ` . This will minimize the number of requests required to load the App in development and allow
115+ for faster developer iteration times.
132116
133117## default.html
134118
@@ -544,9 +528,9 @@ export const actions = {
544528```
545529
546530By maintaining non-UI side-effects that indirectly trigger state changes in middleware similar to how we're
547- maintaining Reducers, we're in essence just leveraging the pub/sub and automatic state synchronization
548- feature in Redux . Among other benefits this now lets any component trigger any effect with a normal message
549- dispatch:
531+ maintaining Reducers, we're leveraging the pub/sub and automatic state synchronization features in Redux in
532+ order to communicate between components . Among other benefits this now lets any component trigger any
533+ action with a normal message dispatch:
550534
551535``` typescript
552536store .dispatch ({ type: ' USERS_REFRESH' });
@@ -556,10 +540,12 @@ store.dispatch({ type: 'MESSAGES_POST', message:'Hello, World!' });
556540
557541## Chat App Components
558542
559- The Redux store is the conduit of how all our App components fit together with the ` @reduxify() ` annotation
560- declaratively capturing both the ** inputs** and ** outputs** that each component needs. The only thing
561- that remains is importing all existing logic into the different React components and wire them to use
562- injected component properties:
543+ The Redux store is the conduit binding all App components together to the App state, the relationships
544+ of which are declared in the ` @reduxify() ` annotation which captures both the ** inputs** and ** outputs**
545+ each component needs - both are injected into the React Component via properties.
546+
547+ With the structre in-place all that remains is to import all existing logic into their different
548+ React Components and wire them to use injected properties:
563549
564550#### [ app.tsx] ( https://github.com/ServiceStackApps/ReactChat/blob/master/src/ReactChat/ReactChat/src/app.tsx )
565551
@@ -1039,9 +1025,9 @@ enum Keys {
10391025
10401026## Packaging and Deployment
10411027
1042- With the React Components above we now have a complete front-end Chat Application , what's next is to stage
1043- our app by running the **default** Gulp task which copies all our project client and server resources
1044- into the ` wwwroot / ` staging folder:
1028+ With the React Components above we now have a complete front-end Chat App , what's next is to package
1029+ our app for production by running the **default** Gulp task which copies all our project client and server
1030+ resources into the ` wwwroot / ` staging folder:
10451031
10461032 wwwroot/
10471033 bin/
@@ -1058,8 +1044,8 @@ into the `wwwroot/` staging folder:
10581044
10591045The
10601046[wwwroot_build/deploy/](https://github.com/ServiceStackApps/ReactChat/tree/master/src/ReactChat/ReactChat/wwwroot_build/deploy)
1061- folder contains files you want available for production and copied into the staged folder which we use to
1062- store and copy the production ` appsettings .txt ` that override default ` < appSettings / > ` .
1047+ folder contains any additional files you want available for production which are also copied into the
1048+ staging folder and is whate we use to copy the production ` appsettings .txt ` to override default ` < appSettings / > ` .
10631049
10641050The result is a complete stand-alone ASP.NET Web Application that's ready for production deployment which
10651051we can deploy by populating ` wwwroot_build / publish / config .json ` with MS WebDeploy settings:
@@ -1073,14 +1059,10 @@ we can deploy by populating `wwwroot_build/publish/config.json` with MS WebDeplo
10731059}
10741060` ` `
10751061
1076- > If you are using Github's default **VisualStudio** ignore template, this file will not be included in
1077- source control due to the default ` publish / ` folder being ignored. If you're not you'll want to ensure
1078- this sensitive config.json is not committed into a public repository.
1079-
1080- Then run the **03-deploy-app** Gulp task which packages the staging ` wwwroot / ` folder into the
1081- ` webdeploy .zip ` package that is deployed using MS WebDeploy to the ` serverAddress ` in the ` config .json ` above.
1062+ Then running the **03-deploy-app** Gulp task which creates a ` webdeploy .zip ` package of the staging ` wwwroot / `
1063+ folder and deploys it using MS WebDeploy to the remote ` serverAddress ` specified in the ` config .json ` .
10821064
1083- When the **03-deploy-app** Gulp task completes you can open it up in your browser to see the latest changes!
1065+ When **03-deploy-app** completes you can open the remote address in your browser to see the latest changes!
10841066
10851067[](http://react-chat.servicestack.net/)
10861068
@@ -1090,4 +1072,21 @@ The Gulp deploy task shows a quick way of updating your development server quick
10901072your application. For more information on use web-deploy using either Gulp or just Visual Studio publish,
10911073see [WebDeploy with AWS](https://github.com/ServiceStack/ServiceStack/wiki/Simple-Deployments-to-AWS-with-WebDeploy).
10921074
1075+ ### .gitignore
1076+
1077+ Similar to how we ignore NuGet ` packages / ` folder in **.gitignore** to avoid checking them into our Git
1078+ repository, we'll want to do the same for npm, jspm and typing folders as well. We also don't need to
1079+ check in the staging ` wwwroot / ` folder or the ` webdeploy .zip ` MS WebDeploy package that our Gulp script
1080+ generates for us, which we can all ignore by adding them to Git repositories **.gitignore**:
1081+
1082+ ` ` `
1083+ node_modules /
1084+ jspm_packages /
1085+ typings /
1086+ wwwroot /
1087+ webdeploy .zip
1088+ ` ` `
10931089
1090+ If you're using Github's default **VisualStudio** ignore template the ` publish / ` folder will be ignored
1091+ by default. If you're not you'll also want to include ` publish / ` so the sensitive ` publish / config .json `
1092+ does not get committed to a public repo.
0 commit comments