I ran into a problem while testing Elm. I want to pass a union type through a port, but I get this error:
Port 'setStorage' is trying to communicate an unsupported type. 34| port setStorage : Model -> Cmd msg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The specific unsupported type is: Todo.Importance The types of values that can flow through in and out of Elm include: Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, Tuples, Json.Values, and concrete records.
I modified the Todo example as follows:
type alias Task = { description : String , completed : Bool , editing : Bool , id : Int , importance : Importance -- <- this is the new field } type Importance = Normal | High | Low
This problem seems pretty old. One commenter suggests "passing Json.Values โโthrough the ports and Json.Decode / Encode them", but how exactly can this be done? The documentation looks a bit obscure and does not contain complete examples. Any help is appreciated.
json elm
Nikolai Koudelia
source share