Javascript to Elm

41: Refactor the Model for Greater Good

Informações:

Sinopsis

Steps Get it working Get onSubmit to POST to the API And onChange for the file input to do the PORT access to FileRead() that we build. Remember we need to use ports to read in the file in base 64 Then pass it back to our Elm app until the user submits the note Then off it goes, back over ports to the the api via POST, The page is popped back to the list, which fetches the whole thing — again. And around and around we go. Let’s see the model type alias CreateNote = { content : String , imageFile : Maybe Image } type alias Model = { notes : List Note , isAuthenticated : Bool , route : Route , createNote : CreateNote } type alias Flags = { route : String } So things have gotten a bit convoluted over time. Refactor the model Thinking about the state of your app We have Logged In Anonymous For each of these states, whether there is a List of type Note or not is predetermined. Now within Logged in we have a variety of of possible states, no notes, fetc