Skip to content
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

Should selections be immutable? Or should selection.data modify in-place? #23

Closed
mbostock opened this issue May 19, 2015 · 2 comments
Closed

Comments

@mbostock
Copy link
Member

I can see arguments to both sides. Normally I’d lean towards immutability, but there’s already the case in D3 3.x where enter.select modifies the update groups in-place, and this is quite convenient. It feels like D3 3 (and prior) is sort of in a middle ground where enter.select modifies in place but selection.data returns a new selection. It would be better to either go for full immutability, or go for mutability and look for places where we can make the API more convenient.

(Also, selection.sort is another place where selections are mutable. So for immutability, this would also need to return a new selection.)

@jeffdn
Copy link

jeffdn commented May 20, 2015

I would argue that it should modify in-place. It is incredibly convenient for charts that are full of transitions to persist your selection, and pass it a new dataset on demand. Of course, were selections to become immutable, it would not be difficult to work around, but if I had a vote, it'd be to retain the current behavior.

@mbostock
Copy link
Member Author

OK, going for mutability.

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

No branches or pull requests

2 participants