ironbar-persea/frontend/app/editor/index.js
2019-03-05 23:20:26 -06:00

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;
}
},
});