react + redux + RR
It uses https://gist.github.com/iNikNik/3c1b870f63dc0de67c38 for stores and actions.
1) create redux
const redux = createRedux(state);
2) get requireAccess func => bindCheckAuth to redux
react + redux + RR
It uses https://gist.github.com/iNikNik/3c1b870f63dc0de67c38 for stores and actions.
1) create redux
const redux = createRedux(state);
2) get requireAccess func => bindCheckAuth to redux
import { createStore } from 'redux'; | |
import { performanceMiddleware, performanceReducer, performancePrintTable } from './redux/util/performance'; | |
import thunkMiddleware from 'redux/lib/middleware/thunk'; | |
import promiseMiddleware from './redux/middleware/promiseMiddleware'; | |
import * as reducers from './reducers/index'; | |
// Util functions. | |
function asyncAction(promise, request, success, failure) { | |
return { types: [request, success, failure], promise }; | |
} |
I would recommend @acdlite's redux-actions over the methods suggested in this Gist.
The methods below can break hot-reloading and don't support Promise-based actions.
Even though 'redux-actions' still uses constants, I've come to terms with the fact that constants can be good, especially in bigger projects. You can reduce boilerplate in different places, as described in the redux docs here: http://gaearon.github.io/redux/docs/recipes/ReducingBoilerplate.html
cover(width = inherit, height = inherit, min-width = 100%, min-height = 100%) | |
// Chrome, Safari | |
@media screen and (-webkit-min-device-pixel-ratio: 0) | |
object-fit cover | |
height height | |
width width | |
// Firefox | |
@-moz-document url-prefix() | |
& | |
object-fit cover |
// ------------ | |
// counterStore.js | |
// ------------ | |
import { | |
INCREMENT_COUNTER, | |
DECREMENT_COUNTER | |
} from '../constants/ActionTypes'; | |
const initialState = { counter: 0 }; |
// https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/retrywhen.md | |
function exponentialBackOffScheduler(options) { | |
return function(errors) { | |
return errors.scan(options, function(currentOptions, err) { | |
if (currentOptions.maxRetries <= 0) { | |
throw err; | |
} | |
return { | |
maxRetries: currentOptions.maxRetries - 1, |
React now supports the use of ES6 classes as an alternative to React.createClass()
.
React's concept of Mixins, however, doesn't have a corollary when using ES6 classes. This left the community without an established pattern for code that both handles cross-cutting concerns and requires access to Component Life Cycle Methods.
In this gist, @sebmarkbage proposed an alternative pattern to React mixins: decorate components with a wrapping "higher order" component that handles whatever lifecycle methods it needs to and then invokes the wrapped component in its render()
method, passing through props
.
While a viable solution, this has a few drawbacks:
This post has moved to my personal blog: http://maximilianschmitt.me/posts/iojs-command-line-apps-nodejs/