Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 917 Bytes

README.md

File metadata and controls

32 lines (25 loc) · 917 Bytes

Description

Custom reselect selector with the ability to log all recomputations with the output similar to redux-logger

Inspired by https://github.com/kbrownlees/reselect-change-memoize and https://github.com/LogRocket/redux-logger

Usage

Standard reselect use case example:

import { createSelector } from 'reselect';

const shopItemsSelector = state => state.shop.items
const taxPercentSelector = state => state.shop.taxPercent

const subtotalSelector = createSelector(
  shopItemsSelector,
  items => items.reduce((acc, item) => acc + item.value, 0)
)

With logged selector:

import createLoggedSelector from 'logged-selector';

const shopItemsSelector = state => state.shop.items
const taxPercentSelector = state => state.shop.taxPercent

const subtotalSelector = createLoggedSelector(
  'subtotalSelector',
  shopItemsSelector,
  items => items.reduce((acc, item) => acc + item.value, 0)
)