-
Notifications
You must be signed in to change notification settings - Fork 328
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
Visibility #55
Comments
I was sketching out some Elm this morning and stumbled upon this nuance myself: strings are easy to mistype. 🤔 So yes: How to avoid hard-coding strings in conditionals like this: let
isVisible todo =
case visibility of
"Completed" ->
todo.completed
"Active" ->
not todo.completed
So here, if I say |
I’ve tried (https://github.com/gurdiga/elm-todomvc/commit/8977837b0e35458323bfddc79fe63cac9f019d5f) to replace hardcoded strings with a
which I only partly understand: I understand that it doesn’t know how to serialize/deserialize Since it points to the main function declaration, I suspect this may be related to I’m also wondering if this approach makes sense at all. 😊 |
@gurdiga I am still new to Elm but here is my implementation and I used union types. https://github.com/mez/elm-todo/blob/master/Todo.elm#L14 |
@mez Haha! Very neat approach here: https://github.com/mez/elm-todo/blob/master/Todo.elm#L198-L207! 😎 Thank you for sharing! |
This is what I got when tried to use union type for visibility in evancz/elm-todomvc:
|
Probably this is the solution for ports http://stackoverflow.com/questions/37999504/how-to-pass-union-types-through-elm-ports/38006565#38006565 or this https://github.com/elm-lang/persistent-cache will be released |
@rofrol persistent cache sounds like a nicer solution. I was at elm-hack night yesterday trying to get ports to work on my todo app and to get around the "union types can't go through ports" issue I just stored the todo items in localstorage 🔨 |
Is there a reason not to use a Union Type for the visibility?
https://github.com/evancz/elm-todomvc/blob/master/Todo.elm#L78
The text was updated successfully, but these errors were encountered: