debois / elm-mdl

Elm-port of the Material Design Lite CSS/JS library
Apache License 2.0
963 stars 133 forks source link

Functions in Msg objects break import/export in Elm 0.18 debugger #318

Open MazeChaZer opened 7 years ago

MazeChaZer commented 7 years ago

Cannot use Import or Export

The Update.Msg type of your program cannot be reliably serialized for history files.

Functions cannot be serialized, nor can values that contain functions. This is a problem in these places:

Material.Dispatch.Config can contain functions and JSON decoders.

The good news is that having values like this in your message type is not so great in the long run. You are better off using simpler data, like union types, in your messages. From there, your update function can pattern match on that data and call whatever functions, JSON decoders, etc. you need. This makes the code much more explicit and easy to follow for other readers (or you in a few months!)

MazeChaZer commented 7 years ago

FYI, not using the global mdl state and wiring up all components individually using their Elm architecture functions solves this problem.

Spiralis commented 6 years ago

@MazeChaZer With the very limited experience I have on Elm and elm-mdl, that sounds like an awful lot of work. Or? Or, is this something that might be fixed at some stage?

MazeChaZer commented 6 years ago

@Spiralis The problem is the general architecture of this libraray, so I don't expect it to be fixed soon.