Skip to content

Instantly share code, notes, and snippets.

View mobinni's full-sized avatar

Mo Binni mobinni

  • Zero To Mastery
  • Toronto, Ontario
View GitHub Profile
@mobinni
mobinni / app.js
Last active January 27, 2016 16:08
A Modern Isomorphic Stack with Redux - Part 2
// Import default Styles
import '../styles/general/styles.scss';
// Import Modules
import React from 'react';
import ReactDOM from 'react-dom';
import createBrowserHistory from 'history/lib/createBrowserHistory'
import Router from 'react-router';
import routes from './routes';
import {initialise} from '../lib';
@mobinni
mobinni / moduleCollector.js
Last active January 27, 2016 15:12
A Modern Isomorphic Stack with Redux - Part 2
class ModuleCollector {
constructor(config) {
this.actions = [];
this.reducers = [];
this.modules = {};
this.config = config;
}
add(newModule) {
if (typeof newModule === 'function') {
@mobinni
mobinni / storeBuilder.js
Last active January 27, 2016 16:06
A Modern Isomorphic Stack with Redux - Part 2
import { combineReducers, createStore, compose, applyMiddleware } from 'redux';
import DevTools from '../tools/devtools';
function _buildStore(middlewares, reducers) {
let functions = [applyMiddleware(...middlewares)];
if (process.env.feature.DEV) {
functions.push(require('../tools/devtools').default.instrument());
}
return compose(
...functions
@mobinni
mobinni / index.js
Last active January 24, 2016 22:31
A Modern Isomorphic Stack with Redux - Part 2
import ModuleCollector from './modules/moduleCollector';
import storeBuilder from './store/storeBuilder';
import feed from './modules/feed';
export function initialise(customMiddlewares = []) {
const moduleCollector = new ModuleCollector();
moduleCollector.add(feed);
const coreReducers = moduleCollector.getReducers();
@mobinni
mobinni / reducers.js
Created January 24, 2016 22:24
A Modern Isomorphic Stack with Redux - Part 2
function feeds(state = [], action) {
if (action.type === 'get') return action.payload;
else return state;
}
export default {
feeds
}
@mobinni
mobinni / actions.js
Last active January 27, 2016 15:10
A Modern Isomorphic Stack with Redux - Part 2
export default function (config) {
return {
loadFeeds() {
return { type: 'get', payload: ['feed 1', 'feed 2', 'feed 3'] }
}
}
}
@mobinni
mobinni / index.js
Last active January 27, 2016 15:10
A Modern Isomorphic Stack with Redux - Part 2
import actions from './actions';
import reducers from './reducers';
export default (config) => {
return {
actions: actions(config),
reducers,
name: 'feed'
};
};
@mobinni
mobinni / folder-structure.txt
Last active January 23, 2016 17:03
A Modern Isomorphic Stack with Redux - Part 2
.
├── app
│   ├── images
│   ├── index.html
│   ├── lib
│   │   ├── index.js
│   │   ├── middleware
│   │   ├── modules
│   │   │   ├── feed
│   │   │   │   ├── actions.js
@mobinni
mobinni / render.js
Last active December 17, 2015 23:33
A Modern Isomorphic Stack with Redux - Part 1
import {RoutingContext} from 'react-router';
import ejs from 'ejs';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
const _renderComponents = (props) => {
return ReactDOMServer.renderToString(
<RoutingContext {...props} />
);
};
@mobinni
mobinni / routing.js
Last active December 17, 2015 23:40
A Modern Isomorphic Stack with Redux - Part 1
/**
* Created by mobinni on 08/12/15.
*/
import webpack from './webpack';
import { match } from 'react-router';
import createLocation from 'history/lib/createLocation';
import {env} from '../utils';
import {renderEngine} from '../engines';
import routes from '../../app/scripts/routes';