rsnext/examples/with-redux-saga/actions.js

53 lines
947 B
JavaScript
Raw Normal View History

2017-07-13 20:55:29 +02:00
export const actionTypes = {
FAILURE: 'FAILURE',
INCREMENT: 'INCREMENT',
DECREMENT: 'DECREMENT',
RESET: 'RESET',
2017-07-13 20:55:29 +02:00
LOAD_DATA: 'LOAD_DATA',
LOAD_DATA_SUCCESS: 'LOAD_DATA_SUCCESS',
START_CLOCK: 'START_CLOCK',
TICK_CLOCK: 'TICK_CLOCK',
2017-07-13 20:55:29 +02:00
}
export function failure(error) {
2017-07-13 20:55:29 +02:00
return {
type: actionTypes.FAILURE,
error,
2017-07-13 20:55:29 +02:00
}
}
export function increment() {
return { type: actionTypes.INCREMENT }
2017-07-13 20:55:29 +02:00
}
export function decrement() {
return { type: actionTypes.DECREMENT }
}
export function reset() {
return { type: actionTypes.RESET }
}
export function loadData() {
return { type: actionTypes.LOAD_DATA }
2017-07-13 20:55:29 +02:00
}
export function loadDataSuccess(data) {
2017-07-13 20:55:29 +02:00
return {
type: actionTypes.LOAD_DATA_SUCCESS,
data,
2017-07-13 20:55:29 +02:00
}
}
export function startClock() {
return { type: actionTypes.START_CLOCK }
2017-07-13 20:55:29 +02:00
}
export function tickClock(isServer) {
2017-07-13 20:55:29 +02:00
return {
type: actionTypes.TICK_CLOCK,
light: !isServer,
ts: Date.now(),
2017-07-13 20:55:29 +02:00
}
}