Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Added redux-saga to complex example
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmr committed Oct 7, 2016
1 parent 59d689a commit 480ed1d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/complex/roc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
koaMiddlewares: 'src/koa-middlewares.js',
redux: {
middlewares: 'src/middlewares.js',
sagas: 'src/sagas.js',
},
reducers: 'src/reducers.js',
routes: 'src/routes.js',
Expand Down
1 change: 1 addition & 0 deletions examples/complex/src/components/about/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { provideHooks } from 'redial';
}),
defer: (locals) => {
locals.setProps({color: 'red'});
locals.dispatch({ type: 'CLICKED_ASYNC' });
},
})
export default class About extends Component {
Expand Down
4 changes: 3 additions & 1 deletion examples/complex/src/components/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ function mapDispatchToProps(dispatch) {
}

// fetch triggers on both server and client
@provideHooks({ fetch: prefetchRepos })
@provideHooks({
fetch: prefetchRepos
})
// mergeReposProps enriches dispatch props with reposForceFetch
@connect(mapStateToProps, mapDispatchToProps, mergeReposProps)
export default class Main extends React.Component {
Expand Down
12 changes: 12 additions & 0 deletions examples/complex/src/sagas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { takeEvery } from 'redux-saga'
import { put, call } from 'redux-saga/effects'
import { delay } from 'redux-saga'

export function* incrementAsync() {
yield call(delay, 1000)
yield put({type: 'CLICKED'})
}

export default function* rootSaga() {
yield* takeEvery('CLICKED_ASYNC', incrementAsync)
}

0 comments on commit 480ed1d

Please sign in to comment.