Sha256: 6046c81c2de789d8322dc31e345aabdbfd62b9a0d9b608ed9264cb115d4a724c

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

export default (state = [], action) => {
  switch (action.type) {
    case "ADD_ARTICLES":
      return [...state, ...action.payload.articles];
    case "REMOVE_ARTICLE":
      return state.filter(article => article.id !== action.payload.id);
    case "SET_ARTICLES":
      return [...action.payload.articles];
    case "UPDATE_ARTICLE":
      return [
        ...state.slice(0, action.payload.index),
        action.payload.article,
        ...state.slice(action.payload.index + 1)
      ];
    default:
      return state;
  }
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loco-rails-3.0.4 test/dummy/frontend/js/reducers/user/articles.js