Giter Club home page Giter Club logo

dynamic-selectors's Introduction

Dynamic Selectors

Selectors with parameters and dynamic dependencies.

See Selector Comparison for a walkthrough.

build status test coverage

Packages

npm version test coverage dependencies status gzip size

Core functionality for dynamic selectors, independent of any other library.
This is the main package.

npm version test coverage dependencies status gzip size

Call Reselect selectors from within dynamic selectors, and use dynamic selectors as dependencies for Reselect selectors.

What is this?

Selectors are memoized functions that transform data -- like computing a derived value from state -- which only re-run when their dependencies change. Reselect is a popular selector library: Redux's Deriving Data with Selectors doc is a good introduction to them.

Dynamic selectors are built like plain functions. There is no up-front registration to connect selectors together, you can pass arguments to them, and they can call each other just like regular functions.

This may be used with a state library like Redux, or on its own as a general memoization util.

Features

Pass arguments to selector functions
Results are memoized by the params you pass to a selector, so selectBooks({ authorId: 3 }) and selectBooks({ authorId: 4 }) will work properly and be cached independently.
Call selectors from within selectors
A selector can call other selectors from if blocks, loops, or any other controls -- or even recursively.
Auto-detected dependencies
When a selector runs, any secondary selectors it calls get marked as dependencies. It won't re-run unless those dependencies return something new. The dependencies can change from one run to the next.
Equality comparisons / caching strategy
Like the useSelector hook, you can specify your own comparison function to 'freeze' updates. This may be customized for each selector.

Comparison between Reselect and Dyanamic Selectors

dynamic-selectors's People

Contributors

dependabot[bot] avatar spautz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.