How to use the redux-starter-kit.createSelector function in redux-starter-kit

To help you get started, we’ve selected a few redux-starter-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackoregon / civic / packages / project-disaster-trail / src / state / orbs.js View on Github external
export default orbs;

// SELECTORS

export const getOrbs = createSelector(
  ["orbs.orbs"],
  orbModels => orbModels
);
export const getOrbById = createSelector(
  ["orbs.orbs", "id"],
  (orbModels, id) => {
    return orbModels[id];
  }
);

export const getOrbsTouched = createSelector([
  "orbs.touchedOrbs",
  touchedOrbs => touchedOrbs
]);

export const getOrbTouched = createSelector(
  ["orbs.touchedOrbs", "id"],
  (touchedOrbs, id) => touchedOrbs.indexOf(id) > -1
);

export const getOrbsComplete = createSelector([
  "orbs.completedOrbs",
  completedOrbs => completedOrbs
]);

export const getOrbComplete = createSelector(
  ["orbs.completedOrbs", "id"],
github hackoregon / civic / packages / 2019-disaster-game / src / state / chapters.js View on Github external
export default chapters;

// SELECTORS

export const getActiveChapterIndex = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => activeChapterIndex
);

export const getActiveChapterData = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex]
);

export const getActiveChapterId = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex].id
);

export const getActiveChapterDuration = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex].duration
);

export const getChapterById = createSelector(
  ["id"],
  id => CHAPTERS.find(chapter => chapter.id === id)
);
github hackoregon / civic / packages / 2019-disaster-game / src / state / tasks.js View on Github external
chapterTimer.reset();
    return initialState;
  }
});
/* eslint-enable no-param-reassign */

export default tasksReducer;

// SELECTORS

export const getEndingChapter = createSelector(
  ["tasks.endingChapter"],
  endingChapter => endingChapter
);

export const getAllTasks = createSelector(
  ["tasks.tasks"],
  _tasks => _tasks
);

export const getActiveTask = createSelector(
  ["tasks.taskOrder", "tasks.activeTaskIndex"],
  (taskOrder, activeTaskIndex) => {
    return taskOrder[activeTaskIndex];
  }
);

export const getActiveTaskIndex = createSelector(
  ["tasks.activeTaskIndex"],
  activeTaskIndex => activeTaskIndex
);
github hackoregon / civic / packages / project-disaster-trail / src / state / settings.js View on Github external
// INITIAL STATE
const initialState = SettingsFactory.getInitialSettings();

// CONSTANTS
export const actionTypes = {};

// ACTIONS

// REDUCERS
export const settings = createReducer(initialState, {});

export default settings;

// SELECTORS

export const getOrbCount = createSelector(
  ["settings.orbCount"],
  orbCount => orbCount
);

export const getOrbSize = createSelector(
  ["settings.orbSize"],
  orbSize => orbSize
);

export const getPeriod = createSelector(
  ["settings.period"],
  period => period
);

export const getVelocityRange = createSelector(
  [
github hackoregon / civic / packages / 2019-disaster-game / src / state / tasks.js View on Github external
imageAlt: taskData.imageAlt,
        locations: taskData.locations,
        weighting: modifiedTaskWeight,
        points: taskData.points
      };
      result.push(genericItem);

      return result;
    }, []);

    return possibleTasks;
  }
);

// Returns pets / people save obj. Doesn't include first 2 "Save Yourself" tasks
export const getSavedMetrics = createSelector(
  ["tasks.taskOrder"],
  taskOrder => {
    return taskOrder.reduce(
      (accumulator, task, index) => {
        if (index > 1) {
          accumulator.people += task.completedResults.people;
          accumulator.pets += task.completedResults.pets;
        }
        return accumulator;
      },
      {
        people: 0,
        pets: 0
      }
    );
  }
github hackoregon / civic / packages / 2019-disaster-game / src / state / tasks.js View on Github external
chapterTimer.reset();
    return initialState;
  }
});
/* eslint-enable no-param-reassign */

export default tasksReducer;

// SELECTORS

export const getEndingChapter = createSelector(
  ["tasks.endingChapter"],
  endingChapter => endingChapter
);

export const getAllTasks = createSelector(
  ["tasks.tasks"],
  _tasks => _tasks
);

export const getActiveTask = createSelector(
  ["tasks.taskOrder", "tasks.activeTaskIndex"],
  (taskOrder, activeTaskIndex) => {
    return taskOrder[activeTaskIndex];
  }
);

export const getActiveTaskIndex = createSelector(
  ["tasks.activeTaskIndex"],
  activeTaskIndex => activeTaskIndex
);
github hackoregon / civic / packages / 2019-disaster-game / src / state / tasks.js View on Github external
export const getActiveTaskIndex = createSelector(
  ["tasks.activeTaskIndex"],
  activeTaskIndex => activeTaskIndex
);

export const getTaskPhase = createSelector(
  ["tasks.activeTaskPhase"],
  activeTaskPhase => activeTaskPhase
);

export const getAllTaskPhaseData = createSelector(
  ["tasks.taskPhases"],
  allTaskPhaseData => allTaskPhaseData
);

export const getWeightedTasks = createSelector(
  ["tasks.tasks", "tasks.tasksForEnvironment", "tasks.activeEnvironment"],
  (allTasks, tasksForEnv, activeEnvironment) => {
    const environmentTasks = tasksForEnv[activeEnvironment];
    const environmentTasksArray = [].concat(
      environmentTasks.saveYourself,
      environmentTasks.saveOthers
    );
    const genericWeighting = 1 / size(allTasks);

    const possibleTasks = Object.keys(allTasks).reduce((result, taskKey) => {
      const taskData = allTasks[taskKey];
      const modifiedTaskWeight = environmentTasksArray.includes(taskData.id)
        ? genericWeighting * 2
        : genericWeighting;

      const genericItem = {
github hackoregon / civic / packages / 2019-disaster-game / src / state / chapters.js View on Github external
export const getActiveChapterIndex = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => activeChapterIndex
);

export const getActiveChapterData = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex]
);

export const getActiveChapterId = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex].id
);

export const getActiveChapterDuration = createSelector(
  ["chapters.activeChapterIndex"],
  activeChapterIndex => CHAPTERS[activeChapterIndex].duration
);

export const getChapterById = createSelector(
  ["id"],
  id => CHAPTERS.find(chapter => chapter.id === id)
);
github hackoregon / civic / packages / 2019-disaster-game / src / state / tasks.js View on Github external
(accumulator, task, index) => {
        if (index > 1) {
          accumulator.people += task.completedResults.people;
          accumulator.pets += task.completedResults.pets;
        }
        return accumulator;
      },
      {
        people: 0,
        pets: 0
      }
    );
  }
);

export const getBadges = createSelector(
  ["tasks.badges"],
  _badges => _badges
);

export const getNextBadgeToShow = createSelector(
  ["tasks"],
  _tasks => getNewBadgeEarned(_tasks)
);

export const getFinalBadgeShown = createSelector(
  ["tasks.finalBadgeShown"],
  finalBadgeShown => finalBadgeShown
);
github hackoregon / civic / packages / project-disaster-trail / src / state / orbs.js View on Github external
export const getOrbsTouched = createSelector([
  "orbs.touchedOrbs",
  touchedOrbs => touchedOrbs
]);

export const getOrbTouched = createSelector(
  ["orbs.touchedOrbs", "id"],
  (touchedOrbs, id) => touchedOrbs.indexOf(id) > -1
);

export const getOrbsComplete = createSelector([
  "orbs.completedOrbs",
  completedOrbs => completedOrbs
]);

export const getOrbComplete = createSelector(
  ["orbs.completedOrbs", "id"],
  (completedOrbs, id) => completedOrbs.indexOf(id) > -1
);

redux-starter-kit

A simple set of tools to make using Redux easier

MIT
Latest version published 5 years ago

Package Health Score

78 / 100
Full package analysis