Skip to content

AdeonMaster/logged-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published