I have a search results page built in Elm where I'd like to encode as much state in to the URL as possible, so that URLs can be passed through Slack, JIRA tickets, et cetera and the receiver will see the same results as the sender.
The page uses this package to build a sortable table of results, and inkuzmin/elm-multiselect
to let the user select the columns to show in the table.
(Table.Config is not stored in the Model, as directed in the README, instead the config is assembled by filtering a list of all possible columns against the selection in the multiselect control.)
The multiselect control has functions to get the selected values and set the selected values. I have used that to integrate the selected columns with the URL: a selection change triggers a URL change, and a URL change can cause a selection change.
Would you be open to the addition of similar functions to this package?
I would picture them being something like:
getSortState : State -> (String, Bool)
sortBy : String -> Bool -> State
or maybe
sortedColumn : State -> String
isReversed : State -> Bool
sortBy : String -> Bool -> State
Another option is to expose the constructor for the State type, which would allow code to destructure the type:
case state of
State column reversed ->
...
But, I think this last option is less interesting because it couples clients more tightly to the current structure of State. I prefer the middle option, with separate functions for the column and the reversed state. Avoiding the tupled return value seems nice.