rsnext/examples/with-redux-thunk/actions.js
Matt Carlotta ffa4089b18
Update with-redux-thunk example to include HMR (#11816)
* Update with-redux-thunk example to include HMR

* Update README

* Fix clock component

* Fix example component

* Fix README
2020-04-14 18:36:50 -05:00

23 lines
655 B
JavaScript

import * as types from './types'
// INITIALIZES CLOCK ON SERVER
export const serverRenderClock = isServer => dispatch =>
dispatch({
type: types.TICK,
payload: { light: !isServer, ts: Date.now() },
})
// INITIALIZES CLOCK ON CLIENT
export const startClock = () => dispatch =>
setInterval(() => {
dispatch({ type: types.TICK, payload: { light: true, ts: Date.now() } })
}, 1000)
// INCREMENT COUNTER BY 1
export const incrementCount = () => ({ type: types.INCREMENT })
// DECREMENT COUNTER BY 1
export const decrementCount = () => ({ type: types.DECREMENT })
// RESET COUNTER
export const resetCount = () => ({ type: types.RESET })