mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Also updated the tick interval to one second, the clock works better this way and this is how the with-redux example is currently implemented as well.
This commit is contained in:
parent
7d7deca1b3
commit
e3079187fd
|
@ -61,7 +61,7 @@ The second example, under `components/add-count.js`, shows a simple add counter
|
|||
|
||||
## What changed with next-redux-saga
|
||||
|
||||
The digital clock is updated every 800ms using the `runClockSaga` found in `saga.js`.
|
||||
The digital clock is updated every second using the `runClockSaga` found in `saga.js`.
|
||||
|
||||
All pages are also being wrapped by `next-redux-saga` using a helper function from `store.js`:
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import React from 'react'
|
||||
|
||||
import {increment, loadData, startClock} from '../actions'
|
||||
import {increment, loadData, startClock, tickClock} from '../actions'
|
||||
import {withReduxSaga} from '../store'
|
||||
import Page from '../components/page'
|
||||
|
||||
class Counter extends React.Component {
|
||||
static async getInitialProps ({store}) {
|
||||
static async getInitialProps ({store, isServer}) {
|
||||
store.dispatch(tickClock(isServer))
|
||||
store.dispatch(increment())
|
||||
if (!store.getState().placeholderData) {
|
||||
store.dispatch(loadData())
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import React from 'react'
|
||||
|
||||
import {increment, startClock} from '../actions'
|
||||
import {increment, startClock, tickClock} from '../actions'
|
||||
import {withReduxSaga} from '../store'
|
||||
import Page from '../components/page'
|
||||
|
||||
class Counter extends React.Component {
|
||||
static async getInitialProps ({store}) {
|
||||
static async getInitialProps ({store, isServer}) {
|
||||
store.dispatch(tickClock(isServer))
|
||||
store.dispatch(increment())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ function * runClockSaga () {
|
|||
yield take(actionTypes.START_CLOCK)
|
||||
while (true) {
|
||||
yield put(tickClock(false))
|
||||
yield call(delay, 800)
|
||||
yield call(delay, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue