Skip to content

Latest commit

 

History

History
59 lines (35 loc) · 2.12 KB

README.md

File metadata and controls

59 lines (35 loc) · 2.12 KB

selectors

Utility functions to use selectors for decoupled React components with a global Redux state.

Installation

npm install --save @modular-toolkit/selectors

Note: by default, the npm package exposes ES5-compatible code (transpiled through Babel).

If you want to use the untranspiled code (highly recommended), us the esnext version, which is included in the same npm package (more info here).

API

This is a drop in replacement for reselect.createSelector and is used to create composed, cachable selectors.

This drop-in replacement is required, because the original function provided by Reselect does not play nicely with the registerSelectorsForUseWithGlobalState module.

This utility function allows you to register selectors that use the context of a self-contained module to a global Redux state.

For an example, take a look at this code from the demo app:

import { registerSelectorsForUseWithGlobalState } from '@modular-toolkit/selectors';
import * as hackerNewsSelectors from '@modular-toolkit/demo-module/selectors';

export default () => registerSelectorsForUseWithGlobalState(
    'modules.hackerNews',
    hackerNewsSelectors
);
  • The first argument is a string that denotes the path to the module's state in the global state
  • The second argument is an object containing the selectors

A version of redux-saga.select, allows you to use the global selector mechanism described above with Sagas.

Change Log

Contribution Guidelines

License

MIT licensed

Copyright © 2018 mobile.de GmbH