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 - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

2

dist/rematch-select.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var lib=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(){return{expose:{select:t.select},init:function(e){var o=e.validate;return{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(n){o([["function"!=typeof e.selectors[n],"Selector ("+e.name+"/"+n+") must be a function"]]),t.select[e.name][n]=function(t){for(var o=[],r=1;arguments.length>r;r++)o[r-1]=arguments[r];return(l=e.selectors)[n].apply(l,[t[e.name]].concat(o));var l}})}}}}}}),index=unwrapExports(lib),lib_1=lib.select;exports.default=index,exports.select=lib_1;
"use strict";function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}Object.defineProperty(exports,"__esModule",{value:!0});var lib=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(e){var n=(void 0===e?{}:e).sliceState,o=void 0===n?function(e,t){return e[t.name]}:n;return{expose:{select:t.select},init:function(e){var n=e.validate;return n([["function"!=typeof o,"The selectPlugin's getState config must be a function. Instead got type "+typeof o+"."]]),{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(r){n([["function"!=typeof e.selectors[r],"Selector ("+e.name+"/"+r+") must be a function"]]),t.select[e.name][r]=function(t){for(var n,c=[],s=1;arguments.length>s;s++)c[s-1]=arguments[s];return(n=e.selectors)[r].apply(n,[o(t,e)].concat(c))}})}}}}}}),index=unwrapExports(lib),lib_1=lib.select;exports.default=index,exports.select=lib_1;
//# sourceMappingURL=rematch-select.cjs.js.map

@@ -1,2 +0,2 @@

function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var lib=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(){return{expose:{select:t.select},init:function(e){var n=e.validate;return{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(o){n([["function"!=typeof e.selectors[o],"Selector ("+e.name+"/"+o+") must be a function"]]),t.select[e.name][o]=function(t){for(var n,r=[],l=1;arguments.length>l;l++)r[l-1]=arguments[l];return(n=e.selectors)[o].apply(n,[t[e.name]].concat(r))}})}}}}}}),index=unwrapExports(lib),lib_1=lib.select;export{lib_1 as select};export default index;
function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var lib=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(e){var n=(void 0===e?{}:e).sliceState,o=void 0===n?function(e,t){return e[t.name]}:n;return{expose:{select:t.select},init:function(e){var n=e.validate;return n([["function"!=typeof o,"The selectPlugin's getState config must be a function. Instead got type "+typeof o+"."]]),{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(r){n([["function"!=typeof e.selectors[r],"Selector ("+e.name+"/"+r+") must be a function"]]),t.select[e.name][r]=function(t){for(var n,c=[],l=1;arguments.length>l;l++)c[l-1]=arguments[l];return(n=e.selectors)[r].apply(n,[o(t,e)].concat(c))}})}}}}}}),index=unwrapExports(lib),lib_1=lib.select;export default index;export{lib_1 as select};
//# sourceMappingURL=rematch-select.esm.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.RematchSelect={})}(this,function(e){"use strict";var t,o,n,c=(t=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(){return{expose:{select:t.select},init:function(e){var o=e.validate;return{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(n){o([["function"!=typeof e.selectors[n],"Selector ("+e.name+"/"+n+") must be a function"]]),t.select[e.name][n]=function(t){for(var o=[],c=1;arguments.length>c;c++)o[c-1]=arguments[c];return(r=e.selectors)[n].apply(r,[t[e.name]].concat(o));var r}})}}}}}},o=void 0,t(o={exports:{}},o.exports),o.exports),r=(n=c,n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n),s=c.select;e.default=r,e.select=s,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.RematchSelect={})}(this,function(e){"use strict";var t,n,o=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.select={};t.default=function(e){var n=(void 0===e?{}:e).sliceState,o=void 0===n?function(e,t){return e[t.name]}:n;return{expose:{select:t.select},init:function(e){var n=e.validate;return n([["function"!=typeof o,"The selectPlugin's getState config must be a function. Instead got type "+typeof o+"."]]),{onModel:function(e){t.select[e.name]={},Object.keys(e.selectors||{}).forEach(function(c){n([["function"!=typeof e.selectors[c],"Selector ("+e.name+"/"+c+") must be a function"]]),t.select[e.name][c]=function(t){for(var n,s=[],f=1;arguments.length>f;f++)s[f-1]=arguments[f];return(n=e.selectors)[c].apply(n,[o(t,e)].concat(s))}})}}}}}}(t={exports:{}},t.exports),t.exports),c=(n=o)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n,s=o.select;e.default=c,e.select=s,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=rematch-select.umd.js.map
{
"name": "@rematch/select",
"version": "0.2.2",
"version": "0.3.0",
"description": "Selectors plugin for Rematch",

@@ -16,3 +16,6 @@ "keywords": [

"license": "ISC",
"author": "Blair Bodnar <blairbodnar@gmail.com> (https://github.com/blairbodnar)",
"authors": [
"Blair Bodnar <blairbodnar@gmail.com> (https://github.com/blairbodnar)",
"Tom Aranda <tga@arandacybersolutions.com> (https://github.com/taranda)"
],
"files": [

@@ -35,3 +38,10 @@ "dist"

"devDependencies": {
"@rematch/core": "^0.3.0"
"@rematch/core": "^0.3.0",
"cross-env": "^5.1.4",
"rimraf": "^2.6.2",
"rollup": "^0.56.5",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^3.0.0",
"uglify-es": "^3.3.9"
},

@@ -38,0 +48,0 @@ "peerDependencies": {

@@ -45,3 +45,4 @@ # Rematch Select

> note: selector state does not refer to the complete state, only the state within the model
> note: By default, the selector state does not refer to the complete state, only the state within the model.
To change this behavior, use the sliceState configuration option described below.

@@ -51,5 +52,7 @@ Selectors can be called anywhere within your app.

```js
import { select, getState } from '@rematch/core'
import { select } from '@rematch/select'
select.cart.total(getState())
const store = init({ ... })
select.cart.total(store.getState())
```

@@ -69,2 +72,40 @@

}
```
```
### Configuration Options
The `selectorPlugin()` method will accept a configuration object with the following property.
#### sliceState:
`sliceState: (rootState, model) => any`
An option that allows the user to specify how the state will be sliced before being passed to the selectors.
The function takes the `rootState` as the first parameter and the `model` corresponding to the selector as the
second parameter. It should return the desired state slice required by the selector.
The default is to return the slice of the state that corresponds to the owning model's name,
but this assumes the store is a Javascript object. Most of the time the default should be used.
However, there are some cases where one may want to specify the `sliceState` function.
##### Example 1 - Use the root state in selectors as opposed to a slice:
This can easily be accomplished by returning the `rootState` in the `getState` config:
```js
const select = selectorsPlugin({ sliceState: rootState => rootState });
```
Now the `state` parameter that is passed to all of the selectors will be the root state.
##### Example 2 - Use an Immutable JS object as the store
If you are using an [Immutable.js](https://facebook.github.io/immutable-js/) Map as your store, you will need to slice
the state using [Map.get()](http://facebook.github.io/immutable-js/docs/#/Map/get):
```js
const select = selectorsPlugin({ sliceState: (rootState, model) => rootState.get(model.name) })
```
Now you can use an [Immutable.js Map](http://facebook.github.io/immutable-js/docs/#/Map) as your store and access the
appropriate slice of the state in each of your selectors.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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