Comments (4)
Hey, version 2.5.11
is out with this feature.
Now you can do:
import deepEqual from 'fast-deep-equal'
const logic = kea({
selectors: {
widgetKeys: [
(selectors) => [selectors.widgets],
(widgets) => {
return Object.keys(widgets);
},
null, // PropTypes
deepEqual
],
},
The third element, PropTypes
, is a legacy feature from the olden days, whose removal would be a breaking change. I'll do it in version 3.0, which is actually just around the corner...
from kea.
and sorry for the wait 😅
from kea.
Awesome!! Thank you for backporting that feature, but i do have some suggestions, maybe for the 3.0 version in the future 😅
In my use case, with the new feature, i need to create two selectors, one that creates the new array, and a second one, that checks it's equality. I was wondering, if there is not a better solution for this.
When creating selectors in reselect, it is possible to define a separate method for comparing the result value of that selector, maybe it would be possible to have this too in Kea? Maybe allowing the third parameter in the selector definition to be an object with optional fields, similar to reselect? Something like this:
{
equalityCheck: (a, b) => a === b,
resultEqualityCheck: shallowEqual
}
Also the current syntax is a bit confusing, when having multiple input parameters to the selector, as one comparison function has to check all of those values, but it seems that could be a limitation of how reselect handles things.
To be honest, I don't fully understand how Kea does work underneath, but it seems to me that having an object with some optional configuration options for a selector would make things easier for adding more options in the future.
Saying all that, looking forward for the 3.0 release 😅
from kea.
Oh, I didn't know of this new reselect 4.1 feature.
I just released 2.6, and changed the last array element to just directly takes reselect's memoizeOptions
. You can do this now:
const logic = kea({
selectors: {
widgetKeys: [
(selectors) => [selectors.widgets],
(widgets) => Object.keys(widgets),
null, // PropTypes, will be removed in Kea 3.0
{ resultEqualityCheck: deepEqual },
],
},
})
from kea.
Related Issues (20)
- Error: [KEA] Can not find path "kea.inline.2.01F5GZMSKVYQS0SD7M823JDN8P" in the store. HOT 2
- Unit Test in 2.4 HOT 1
- pass component props to logic HOT 3
- Is there a way to use generics with `MakeLogicType` ? HOT 3
- BindLogic + automatic connections support? HOT 4
- ListenerFunction’s Typescript return type should be " any | Promise<any>" HOT 1
- could Redux be separate from kea? HOT 1
- Using parameters when getting values? HOT 2
- Still having issues to unit test connected components HOT 1
- Updating part of connected logic HOT 2
- Accessing whole state in reducers HOT 1
- Update instructions for Next.js support with SSR HOT 2
- How to test `propsChanged` ? HOT 1
- Kea does not unmount logic when using lazy components with suspense HOT 2
- When will the translation of the document begin? HOT 1
- Link in About on GitHub repo is dead HOT 1
- How to do something like router.pop() HOT 4
- How to access a reducer of same logic into other logic. HOT 3
- Typegen defaultMaximumTruncationLength HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kea.