Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rematch/select

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rematch/select

Selectors plugin for Rematch

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.8K
increased by6.44%
Maintainers
2
Weekly downloads
 
Created
Source

Rematch Select

Selectors plugin for Rematch.

Install

npm install @rematch/select

Setup

import selectorsPlugin from '@rematch/select'
import { init } from '@rematch/core'

const select = selectorsPlugin()

init({
  plugins: [select]
})

selectors

selectors: { [string]: (state, ...params) => any }

Selectors are read-only snippets of state.

{
  name: 'cart',
  state: [{
    price: 42.00,
    amount: 3,
  }],
  selectors: {
    total(state) {
      return state.reduce((a, b) => a + (b.price * b.amount), 0)
    }
  }
}

note: selector state does not refer to the complete state, only the state within the model

Selectors can be called anywhere within your app.

import { select, getState } from '@rematch/core'

select.cart.total(getState())

Selectors can also be used with memoization libraries like reselect.

import { createSelector } from 'reselect'

{
  selectors: {
    total: createSelector(
      state => state.reduce((a, b) => a + (b.price * b.amount), 0)
    )
  }
}

Keywords

FAQs

Package last updated on 28 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc