1.1.5 • Published 1 year ago

@karmaniverous/block-refresh v1.1.5

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
1 year ago

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

Typedefs

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
aanyCurrent useSelector result.
banyLast useSelector result.
optionsObjectOptions object.
options.logstringIf defined, function will console log a & b values with log value as label when refresh is blocked.
options.pathstringA 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.predicateEqalityFnReturns true if refresh should be blocked. If predicate is populated, path & refreshUndefined are ignored.
options.refreshUndefinedbooleanIf 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
aany
bany

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

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.0-1

1 year ago

1.0.5

1 year ago

1.0.0-0

1 year ago

1.0.4

1 year ago

1.0.0-3

1 year ago

1.1.2

1 year ago

1.0.3

1 year ago

1.0.0-2

1 year ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago