resolves a promise with your chosen selection from state when the state allows your predicate to return true
Table of Contents generated with DocToc
$ npm install redux-select-when-matched --prod
import selectWhenMatched from 'redux-select-when-matched';
import {createStore} from 'redux';
import {isLoaded, getResource} from 'duck';
const store = createStore(reducer);
const predicate = state => isLoaded(state, 'foo-type', id);
const selector = state => getResource(state, 'foo-type', id);
selectWhenMatched(store, predicate, selector).then(selectedDetailsFromState => {
// do what you need to with the details that are now available from state
});
requires the raw redux store
, predicate
and selector
for the subscription
your redux store object
accepts the new state as input, allowing you to inspect and return a boolean informing whether or not the promise for this subscription should be resolved
accepted the new state as input, allowing you to select within it to return the subset of state that your subscriber desires
$ nvm install
$ npm install
$ npm test