title: How to dispatch a message in elm (without an event)
body: <p>I am trying to learn Elm, and have been trying to work out the best way to architect a scaleable application. Regarding routing, I want to have some simple logic rendering the various views depending on the current <code>route</code>, emphasis on simple logic. However, inside some of my views, I want to change the route depending on the model. For example, in my <code>Players</code> view, I only want to render it if I have received some data from the server. If the request is pending or failed, I would like to display an error page. I realize I could perform this logic inside the <code>Players</code> view, but I would prefer to dispatch a message to the model to change the route to a different view. I only know how to dispatch messages from events (<code>onClick</code>, etc...). Is this possible or am I working outside the designs of the language? </p>
  
  <p>This is my current setup, but I would like to change </p>
  
  <pre><code>Nothing -&gt;
      notFoundView
  </code></pre>
  
  <p>To dispatch a message that changes the route</p>
  
  <p><strong>Core View</strong></p>
  
  <pre><code>view : Model -&gt; Html Msg
  view model =
      div []
          [ page model
          ]
  
  page : Model -&gt; Html Msg
  page model =
      case model.route of
          PlayersRoute -&gt;
              listView model.playersModel.players
  
          PlayerRoute id -&gt;
              editView model id
  
          NotFoundRoute -&gt;
              notFoundView
  </code></pre>
  
  <p><strong>Players View</strong></p>
  
  <pre><code>editView : Model -&gt; PlayerId -&gt; Html Msg
  editView model id =
      case model.playersModel.players of
          NotAsked -&gt;
              text ""
  
          Loading -&gt;
              text "Loading ..."
  
          Failure err -&gt;
              text (toString err)
  
          Success players -&gt;
              let
                  maybePlayer =
                      players
                          |&gt; List.filter(\player -&gt; player.id == id)
                          |&gt; List.head
              in
                  case maybePlayer of
                      Just player -&gt;
                          core player
  
                      Nothing -&gt;
                          notFoundView
  </code></pre>
  
  <p>Thank you in advance for any help!</p>