Javascript to Elm

26: Ports, JSON, and Elm render

Informações:

Sinopsis

  Data from Ports After being about to do a debug log in the update function that was just a dump of the results from the port function port notesLoaded : (Value -> msg) -> Sub msg This was cause for celebration. Now getting that JSON data into a list. Ok, what is the return payload in ?? Little messed up looking at most examples, bc they were dealing with maybe JSON Result type signature type Result error value = Ok value | Err error A Result is either Ok meaning the computation succeeded, or it is an Err meaning that there was some failure. type Msg = NotesLoaded (Result String Notes) [...] port notesLoaded : (Value -> msg) -> Sub msg Decoding List of Objects. Everyone’s favorite. This is the part I enjoy in programing the sort of gritty, data transformation. incoming JSON is run through the noteListDecoder, which runs decode on a list of Notes. Using map3 we Try three decoders and then combine the result. >> In other words, («) takes 2 functions of types b -> c and a -> b respect