Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v4.0.0-rc2: Record: add back keySeq #1282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zalastax opened this issue Aug 8, 2017 · 1 comment
Closed

v4.0.0-rc2: Record: add back keySeq #1282

Zalastax opened this issue Aug 8, 2017 · 1 comment

Comments

@Zalastax
Copy link

Zalastax commented Aug 8, 2017

As of #1135 Records are no longer collections.
This is fine when using Records explicitly but makes "reflection" difficult, i.e. how do you iterate over each key? Converting to a Seq each time seems very wasteful.
Examples of when I need this: Zalastax/immutable-devtools@13569c7 and Zalastax/tsdiff@29609cc

@leebyron
Copy link
Collaborator

Treating Records as collections is not an API to be encouraged, which is why these functions were removed. For special cases that need to use reflection, converting to Seq is the right decision. Similar to how you might use Object.keys() to reflect on a plain JS Object, rather than assuming that Object to behave like a collection in all cases.

Seq is not wasteful in a performance sense, since it only offers a lazy view over the underlying data - there is very little overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants