32 lines
605 B
JavaScript
32 lines
605 B
JavaScript
import {combineReducers} from 'redux'
|
|
|
|
const types = {
|
|
EDITOR_CREATE_TAB: '@@persea/EDITOR_CREATE_TAB',
|
|
EDITOR_CLOSE_TAB: '@@persea/EDITOR_CLOSE_TAB',
|
|
};
|
|
|
|
const creators = {
|
|
createTab: (title, uri) => {
|
|
return {
|
|
type: types.EDITOR_CREATE_TAB,
|
|
payload: {
|
|
title,
|
|
uri,
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
export const actions = {types, creators};
|
|
|
|
export const reducer = combineReducers({
|
|
tabs: (state = [], action) => {
|
|
switch (action.type) {
|
|
case types.EDITOR_CREATE_TAB:
|
|
return [...state, action.payload];
|
|
default:
|
|
return state;
|
|
}
|
|
},
|
|
});
|