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

async-selector

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-selector - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

package.json
{
"name": "async-selector",
"version": "1.0.5",
"version": "1.0.6",
"description": "Select values from databases using asynchronous selectors.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -123,4 +123,18 @@ A simple, lightweight library inspired by [reselect](https://github.com/reduxjs/reselect) which allows you select data out of a remote database almost as easily as you would from local state. This library will normally be used in conjunction with redux and reselect but it has no dependencies.

```
### Handling stateful APIs
Generally, a basic assumption of a selector is the function is pure - the inputs fully determine the output. Unfortunately, that is an assumption can't always be made when querying a database. For example, you might have a button that allows the user to refresh the data if the user is worried the data was changed. Fortunately, this isn't actually a big issue thanks to the "forceUpdate" parameter!
```
function buttonClicked() {
employeeAges(store.getState(), true) // "true" indicates that the selector should create a new promise regardless of whether the inputs changed
}
```
By passing true as the second parameter of the selector, the selector will be called as if the inputs changed thus automatically creating a new promise.
# Documentation
createAsyncSelector takes in two arguments:
```

@@ -140,3 +154,6 @@ function createAsyncSelector(params, ...selectors) -> obj

## selectors
Each selector is a function that takes in state as its argument just like in reselect. It memoizes its results so the only way for it to return a different value for the same inputs is if it contained a promise that was resolved.
Each selector is a function that takes in state as its argument just like in reselect. It memoizes its results so the only way for it to return a different value for the same inputs is if it contained a promise that was resolved. An async selector is only different from a normal selector in that you can pass in "forceUpdate" bool as the second parameter to force a promise to be made.
```
function selector(state, forceUpdate=false) -> any
```
## params

@@ -143,0 +160,0 @@ params is an object

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