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

Add update_selection/1 to dynamically update (append, filter etc) the selection #68

Open
shamanime opened this issue Jun 9, 2024 · 1 comment · May be fixed by #69
Open

Add update_selection/1 to dynamically update (append, filter etc) the selection #68

shamanime opened this issue Jun 9, 2024 · 1 comment · May be fixed by #69
Assignees
Labels
enhancement New feature or request

Comments

@shamanime
Copy link
Contributor

          Thanks for the explanation. I'm starting to see the value in this approach.

Instead of using 2 new options, one to pass a filter and the other to append to the selection, my suggestion would be to generalize the approach by passing an update_selection/1 function that receives the whole selection and returns the new one:

append case:

values_to_append = [1, 2, 3]

send_update(LiveSelect.Component, id: live_select_id, update_selection: fn selection -> selection ++ values_to_append end)

filter case:

send_update(LiveSelect.Component, id: live_select_id, update_selection: fn selection -> Enum.filter(selection, & &1 > 2)
end)

2 birds with a stone. And this general approach will hopefully accommodate future use cases.

What do you think?

EDIT: this would also make sense in single mode

Originally posted by @maxmarcon in #64 (comment)

@shamanime
Copy link
Contributor Author

@maxmarcon would you please assign me on this

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

Successfully merging a pull request may close this issue.

2 participants