move action type strings to constants
This commit is contained in:
parent
5517141edf
commit
e7c1caf65e
3
src/actions/action_types.js
Normal file
3
src/actions/action_types.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export const TEST_ACTION = 'TEST_ACTION';
|
||||
export const START_LOADING_VIDEOS = 'START_LOADING_VIDEOS';
|
||||
export const RECEIVE_VIDEOS = 'RECEIVE_VIDEOS';
|
|
@ -1,4 +1,5 @@
|
|||
import config from '../config';
|
||||
import { START_LOADING_VIDEOS, RECEIVE_VIDEOS } from './action_types';
|
||||
|
||||
function fetchVideos() {
|
||||
console.log('fetchVideos called');
|
||||
|
@ -34,13 +35,13 @@ function fetchVideos() {
|
|||
|
||||
function startLoadingVideos() {
|
||||
return {
|
||||
type: 'START_LOADING_VIDEOS'
|
||||
type: START_LOADING_VIDEOS
|
||||
}
|
||||
}
|
||||
|
||||
function receiveVideos(videos) {
|
||||
return {
|
||||
type: 'RECEIVE_VIDEOS',
|
||||
type: RECEIVE_VIDEOS,
|
||||
payload: videos
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { TEST_ACTION } from './action_types';
|
||||
|
||||
function testAction(data) {
|
||||
return {
|
||||
type: 'TEST_ACTION',
|
||||
type: TEST_ACTION,
|
||||
payload: data
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
import { TEST_ACTION, START_LOADING_VIDEOS, RECEIVE_VIDEOS } from '../actions/action_types';
|
||||
|
||||
export default function (state = {}, action) {
|
||||
|
||||
switch (action.type) {
|
||||
case 'TEST_ACTION':
|
||||
case TEST_ACTION:
|
||||
return Object.assign({}, state, { test: action.payload });
|
||||
|
||||
case 'START_LOADING_VIDEOS':
|
||||
case START_LOADING_VIDEOS:
|
||||
return Object.assign({}, state, { loading: true });
|
||||
|
||||
case 'RECEIVE_VIDEOS':
|
||||
case RECEIVE_VIDEOS:
|
||||
return Object.assign({}, state, { loading: false, videos: action.payload })
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user