Zaid-Ajaj / the-elmish-book

A practical guide to building modern and reliable web applications in F# from first principles
https://zaid-ajaj.github.io/the-elmish-book
Other
338 stars 51 forks source link

Where does the state value come from? #141

Closed bytesource closed 3 years ago

bytesource commented 4 years ago

Hi Zaid,

In the section Modelling nested routes >> Passing URLs to child programs there is a value state that I'm not sure where it came from:

// App.fs
let init() =
  let currentUrl = parseUrl(Router.currentUrl())
  match currentUrl with
  | Url.User userUrl ->
      let (userState, userCmd) = User.init userUrl
      { state with
          CurrentUrl = currentUrl
          CurrentPage = Page.User userState }, Cmd.map UserMsg userCmd
  // ...

Peeking at the next chapter I saw that you initialized a defaultState inside init(), is this what you are doing here?

Zaid-Ajaj commented 3 years ago

Should be fixed now, thanks for pointing it out and sorry it took so long!

There was no defaultState, here we are just constructing the state with only two fields: CurrentUrl and CurrentPage