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 sortArray function #314

Closed
grubeninspekteur opened this issue Dec 13, 2023 · 4 comments
Closed

Add sortArray function #314

grubeninspekteur opened this issue Dec 13, 2023 · 4 comments

Comments

@grubeninspekteur
Copy link

Please add a function similar to swap and move that takes a form array state and a comparator of FormState and sorts the form array controls.

(I will work on this if you accept the feature)

@MrWolfZ
Copy link
Owner

MrWolfZ commented Dec 13, 2023

I'll gladly accept contributions if you are willing to work on this. At the same time, this seems like quite an edge case requirement and due to the composable nature of ngrx-forms you can easily build and use your own update function and reducer in your code base without having to go through the trouble of contributing it to the library. Let me know what you'd like to do.

@grubeninspekteur
Copy link
Author

grubeninspekteur commented Dec 13, 2023

For now I have done that, but the very helpful computeArrayState function is not exported outside of the package, so I had to copy it and its helper functions. If you are willing to make that a public API, then I would be happy with having the sort function in application code only.

@MrWolfZ
Copy link
Owner

MrWolfZ commented Dec 14, 2023

That's a very good point that I didn't consider. After thinking on it, I'd rather not go through the trouble of making computeArrayState part of the public API, since that would imply a bunch of other APIs needing to be public as well for consistency and having to write a bunch of docs and extra tests.

Therefore, I would prefer if you do contribute the sortArray update function into this repo instead.

@grubeninspekteur
Copy link
Author

Sorry not have gotten back to you. We found that we required the IDs to stay consistent, which goes against the FormArray manipulation functions already present in ngrx/forms. So even if I contributed the function, it would not help in our use case. In light of your comment in #311 that ngrx/forms is in maintenance mode, I'm closing this request.

@grubeninspekteur grubeninspekteur closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants