Socket
Book a DemoInstallSign in
Socket

@karmaniverous/block-refresh

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@karmaniverous/block-refresh

Use as the equalityFn argument to Redux useSelector() when the selected value is an Object.

1.1.5
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

block-refresh

Use as the equalityFn argument to Redux useSelector when the selected value is an Object.

To install:

npm install @karmaniverous/block-refresh

To import:

import { blockRefresh } from '@karmaniverous/block-refresh`;

See tests for examples of usage!

API Documentation

Functions

blockRefresh([a], [b], [options])boolean

Use as the equalityFn argument to Redux useSelector() when the selected value is an Object. https://react-redux.js.org/api/hooks#useselector

Typedefs

EqalityFnboolean

Return true if the two inputs should be considered equal.

blockRefresh([a], [b], [options]) ⇒ boolean

Use as the equalityFn argument to Redux useSelector() when the selected value is an Object. https://react-redux.js.org/api/hooks#useselector

Kind: global function
Returns: boolean - If true, component will not refresh.

ParamTypeDescription
[a]anyCurrent useSelector result.
[b]anyLast useSelector result.
[options]ObjectOptions object.
[options.log]stringIf defined, function will console log a & b values with log value as label when refresh is blocked.
[options.path]stringA Lodash-style path into the selected object. If defined, the equality test will be restricted to that path. Useful when an object has an update timestamp.
[options.predicate]EqalityFnReturns true if refresh should be blocked. If predicate is populated, path & refreshUndefined are ignored.
[options.refreshUndefined]booleanIf true, component will refresh when both comparison values are undefined.

Example

// Passed as a function, it will block component refresh if the current &
// previous values are defined & pass _.isEqual.
const obj = useSelector((state) => state.slice.obj, blockRefresh);

Example

// Deploy as an anonymous function to set options.
const obj = useSelector(
  (state) => state.slice.obj,
  (a, b) => blockRefresh(a, b, options)
);

EqalityFn ⇒ boolean

Return true if the two inputs should be considered equal.

Kind: global typedef

ParamType
[a]any
[b]any

See more great templates and other tools on my GitHub Profile!

Keywords

react

FAQs

Package last updated on 22 Feb 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.