title: Load different resources on urlUpdate elm
body: <p>I am new to elm and functional programming. Hope this is a simple question. What I am trying to do is, when I change views I want elm to fetch records based on the view that it is about to change to. I was hoping I could do it in the urlUpdate method based on the currentRoute. I have two views one for players and one for perks, both have independent commands objects. I tried to do it like this: </p>
  
  
  
  <pre class="lang-elm prettyprint-override"><code>urlUpdate : Result String Route -&gt; Model -&gt; ( Model, Cmd Msg )
  urlUpdate result model =
      let
          currentRoute =
              Routing.routeFromResult result
  
          _ =
              Debug.log "Current Route" currentRoute
      in
          if toString currentRoute == "PerksRoute" then
              ( { model | route = currentRoute }
              , Perks.Commands.fetchAll
              )
          else if toString currentRoute == "PlayersRoute" then
              ( { model | route = currentRoute }
              , Players.Commands.fetchAll
              )
          else
              ( { model | route = currentRoute }, Cmd.none )
  </code></pre>
  
  <p>However I get this error:</p>
  
  <blockquote>
    <p>The 1st branch has this type:</p>
  
  <pre class="lang-elm prettyprint-override"><code>   ( { a | route : Route }, Cmd Perks.Messages.Msg )
  </code></pre>
    
    <p>But the 2nd is:</p>
  
  <pre class="lang-elm prettyprint-override"><code>   ( { a | route : Route }, Cmd Players.Messages.Msg )
  </code></pre>
  </blockquote>
  
  <p>I am not sure why this is happening, I would think that having this Type defined at would be ok.</p>
  
  <pre class="lang-elm prettyprint-override"><code>type Msg
      = PlayersMsg Players.Messages.Msg
      | PerksMsg Perks.Messages.Msg
  </code></pre>
  
  <p>Here is the full <a href="https://github.com/mdemin914/elm-playground/tree/master" rel="nofollow">src</a></p>