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 couple of potentially useful functions #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bobwhitelock
Copy link

Hi @rtfeldman - I've been using this package in a couple of projects recently, where I've found it useful (so thanks 🙂). While using it I've found a couple of situations have reappeared, at least for my use cases:

  • I want to get a SelectList from a List, without selecting a particular element, either because I don't care which this is or because I can immediately pipe this into SelectList.select; since not every List can be turned into a SelectList this operation can fail so should produce a SelectList wrapped in a Maybe (or equivalent).

  • I want to decode a JSON array of some type straight into a SelectList of that type; similarly I either don't care which element is initially selected or can use SelectList.select to handle this.

This PR contains a couple of commits with functions to perform each of these operations. Both of these are reasonably trivial with the current API, but since I found I was repeating them across projects I thought I'd suggest them here.

If you don't think these fit here or are worth adding, then no problem. If you do, or think just one of them is, let me know and I can adjust appropriately and add docs and tests. Either way, thanks in advance.

@wking-io
Copy link

I would love these additions! I created my own version of SelectList in my project without realizing it was a SelectList, but with these two additions I could really see myself using this! @rtfeldman

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

Successfully merging this pull request may close these issues.

2 participants