-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
847d129
commit aebe1cd
Showing
10 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# React scaffolding | ||
|
||
An opinionated scaffolding with the following technical stack and configuration: | ||
|
||
* React (0.13.x) | ||
* React Router (1.x) | ||
* Flux by using Redux (1.x) | ||
* Webpack | ||
* CSS Modules | ||
* Stylus | ||
* Seamless Immutable | ||
* Hot module replacement | ||
* Babel | ||
|
||
The idea is to provide a base structure that enable consumers to start building freatures and deliver a production ready package of a Single Page App. | ||
|
||
|
||
### Bundle process | ||
|
||
The scaffolding provides a feature-rich configuration for delivering the application as well as a rich development experience. | ||
Go [here](./WEBPACK.md) to read more about the details of our bundle process. | ||
|
||
### Architecture (React + Flux) | ||
|
||
### React patterns | ||
|
||
### Other patterns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Webpack | ||
|
||
We use [webpack](http://webpack.github.io/) as our main building tool. | ||
|
||
The following techinques are being used from webpack for enabling a better Development Experience (DX). | ||
|
||
### Loaders for all dependencies in our project. | ||
|
||
Everything in the project gets required through webpack. This means | ||
that we use the 'require' (or ES6 import) statement for requiring ALL the dependencies we might have in the project (including fonts, images, css, etc). | ||
To be able to do this we configure webpack with different loaders that know how to handle the different file types. | ||
|
||
Refer to webpack config for more details and explanation. | ||
|
||
We have different webpack configurations to enable different builds (development, production, test). |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Action Creators | ||
|
||
Action creators are just functions that create the 'Payload' for a given action/operation. | ||
The action creator will get the type from our list of action types and return a literal | ||
with extra parameters if they are required as well as an Api Call in case of an async action. | ||
|
||
Our action creators follow the convention from Redux, for more information on it check the docs | ||
on redux site ([link](http://rackt.github.io/redux/docs/basics/Actions.html)) | ||
|
||
Is important to notice that Action Creators when called they DO NOTHING but create an object | ||
that represents our action, we need to perform a 'dispatch' of this object to actually create | ||
an impact in our App. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Action Types | ||
|
||
Action types are simply constants. | ||
The idea is to define in a single place all the 'String' constants we need for | ||
all the actions in our Application. | ||
The action types can have two different shapes depending if they represent a sync | ||
action or an async action. (this shape is determined by our redux middleware, we just | ||
follow the convention stablished by our custom middleware). | ||
|
||
### Sync | ||
```js | ||
Types = { | ||
POST_READ: "POST_READ" | ||
} | ||
``` | ||
|
||
### Async | ||
```js | ||
Types = { | ||
FETCH_POST: { | ||
request: "FETCH_POST_REQUEST", | ||
done: "FETCH_POST_DONE", | ||
fail: "FETCH_POST_FAIL" | ||
} | ||
} | ||
``` | ||
|
||
We have under utils just some simple functions that simplify the task of creating this action types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import env from "app/utils/env"; | ||
|
||
const list = [ | ||
require("./session"), | ||
]; | ||
|
||
|
||
/* | ||
* Export the merged list of action types. | ||
*/ | ||
export default list.reduce((result, actionTypes) => tryMerge(result, actionTypes), {}); | ||
|
||
|
||
|
||
/** | ||
* Little helper only for Dev, just throw if we find an Action that already exists | ||
* just to make easier the development. | ||
*/ | ||
function tryMerge (obj, newObj) { | ||
|
||
if (env.isDev) { | ||
Object.keys(newObj).forEach(type => { | ||
if (obj[type]) throw new Error(`ActionType: [${type}] already exists`); | ||
}); | ||
} | ||
|
||
return {...obj, ...newObj}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Redux Middleware | ||
|
||
This folder contains the middleware that we use for Redux, for more information on how | ||
to build custom middleware please refer to [docs](http://rackt.github.io/redux/docs/advanced/Middleware.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Reducers | ||
|
||
This folder contains our Redux reducers, for more information on reducers please | ||
refer to ([docs](http://rackt.github.io/redux/docs/basics/Reducers.html)) |