redux-select-when-matched

    2.0.6 • Public • Published

    redux-select-when-matched

    resolves a promise with your chosen selection from state when the state allows your predicate to return true

    Build Status Codecov

    Table of Contents generated with DocToc

    Usage

    npm MIT license

    Installation

    $ npm install redux-select-when-matched --prod

    Subscribing to state changes

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

    API

    subscribe

    requires the raw redux store, predicate and selector for the subscription

    store (required)

    your redux store object

    predicate (required)

    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

    selector (required)

    accepted the new state as input, allowing you to select within it to return the subset of state that your subscriber desires

    Contributing

    Conventional Commits Commitizen friendly semantic-release PRs Welcome Dependabot

    Dependencies

    $ nvm install
    $ npm install

    Verification

    $ npm test

    Keywords

    none

    Install

    npm i redux-select-when-matched

    DownloadsWeekly Downloads

    37

    Version

    2.0.6

    License

    MIT

    Unpacked Size

    11.9 kB

    Total Files

    9

    Last publish

    Collaborators

    • gain-bot