Adds mock saga

This commit is contained in:
Gabriel Delavald 2017-08-16 19:51:37 -03:00
parent 2d9bbb87ae
commit 618d5450dc
5 changed files with 8415 additions and 408 deletions

View File

@ -1,20 +1,25 @@
import 'babel-polyfill';
import 'regenerator-runtime/runtime';
import { createStore, applyMiddleware } from 'redux'; import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk'; import createSagaMiddleware from 'redux-saga';
import logger from 'redux-logger'; import logger from 'redux-logger';
import rootReducer from '../reducers/rootReducer'; import rootReducer from '../reducers/rootReducer';
import helloSaga from '../sagas/hello';
let middleware = [thunk]; const sagaMiddleware = createSagaMiddleware();
let middleware;
if (__DEV__) { if (__DEV__) {
/* eslint-disable global-require */ /* eslint-disable global-require */
const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default(); const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default();
middleware = [...middleware, reduxImmutableStateInvariant, logger]; middleware = [sagaMiddleware, reduxImmutableStateInvariant, logger];
} else { } else {
middleware = [...middleware]; middleware = [sagaMiddleware];
} }
export default createStore( export default createStore(
rootReducer, rootReducer,
undefined, applyMiddleware(sagaMiddleware)
applyMiddleware(...middleware)
); );
sagaMiddleware.run(helloSaga);

17
app/sagas/hello.js Normal file
View File

@ -0,0 +1,17 @@
import { take, fork } from 'redux-saga/effects';
import 'babel-polyfill';
import 'regenerator-runtime/runtime';
const foreverAlone = function* foreverAlone() {
yield take('cagado');
console.log('foi cagado');
yield take('voa');
console.log('o');
};
const root = function* root() {
yield fork(foreverAlone);
};
export default root;

3521
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
}, },
"dependencies": { "dependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.26.0",
"moment": "^2.18.1", "moment": "^2.18.1",
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"react": "16.0.0-alpha.12", "react": "16.0.0-alpha.12",
@ -41,7 +42,8 @@
"redux": "^3.7.2", "redux": "^3.7.2",
"redux-immutable-state-invariant": "^2.0.0", "redux-immutable-state-invariant": "^2.0.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0", "redux-saga": "^0.15.6",
"regenerator-runtime": "^0.11.0",
"strip-ansi": "^4.0.0", "strip-ansi": "^4.0.0",
"underscore": "^1.8.3" "underscore": "^1.8.3"
}, },

5264
yarn.lock Normal file

File diff suppressed because it is too large Load Diff