Skip to content

Commit

Permalink
Adding some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelchiti committed Aug 25, 2015
1 parent 847d129 commit aebe1cd
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

.DS_Store
27 changes: 27 additions & 0 deletions README.md
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
15 changes: 15 additions & 0 deletions WEBPACK.md
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 removed app/.DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions app/action_creators/README.md
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.
3 changes: 1 addition & 2 deletions app/action_creators/session_action_creator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Types from "app/action_types/session";
import Types from "app/action_types/session";

import {
fetchSession as fetchSessionCall,
authenticate as authenticateCall
} from "app/api/api_calls";



export function authenticate (email, password) {
return {
type: Types.AUTHENTICATE,
Expand Down
28 changes: 28 additions & 0 deletions app/action_types/README.md
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.
28 changes: 28 additions & 0 deletions app/action_types/index.js
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};
}
4 changes: 4 additions & 0 deletions app/middleware/README.md
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)
4 changes: 4 additions & 0 deletions app/reducers/README.md
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))

0 comments on commit aebe1cd

Please sign in to comment.