Home

Awesome

Flambeau

Lightweight Redux enhancements with opinions:

Declarative action creators

export function addTodo({ text }) {} // No constants

export function editTodo({ index, text }) {} // Payload is self-documenting

export function completeTodo({ index }) { // Payload can be altered, otherwise defaults to the input.
  return { index, dateCompleted: new Date() };
}

Reusable reducers

export const TodoListActions = {
  addTodo(state, { text }) {
    return state.concat({ text });
  },

  editTodo(state, { index, text }) {
    let newState = state.slice();
    newState[index] = { ...newState[index], text };
    return newState;
  },
  
  completeTodo(state, { index, dateCompleted }) {
    let newState = state.slice();
    newState[index] = { ...newState[index], dateCompleted };
    return newState;
  }
}
// Props are passed in as first argument:
export function getInitialState({ initialItems = [] }) {
  return {
    items: initialItems
  };
}

Reducer state encapsulation

Documentation

Installation

npm install flambeau --save

Examples