Replies: 1 comment 2 replies
-
|
What do you think @bdurrer |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sometime, you just don't want to know if you are working with an immutable object, or a plain JavaScript one.
Imagine the following pseudo React Component:
In that case, Array and List do implements
.map, but there is an issue because List does not implements.length, but only.size.In that case, we will have to do something like this:
That seems really counterproductive.
My proposition is to add an alias
.lengthon every structure to make the API easier to work with.If we do that, then we will add
lengthon every data structure that implements.sizeto be consistant and have an non confusing API.So not only Immutable.List Immutable.Set will have
.length, just like Array and plain Set, but alsoMap().lengthwill exist, even if Javascript object won't (for the record it might have.keyLengthin the future).I don't see any possible breaking change here. The only change is method like
isArrayLike, in immutable or in user-land will now return true.Beta Was this translation helpful? Give feedback.
All reactions