1.0.0 • Published 5 years ago

logged-selector v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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)
)