title: How to observe game stats over a whole session?
body: <p>I am creating Tic Tac Toe in Angular, and I'd like to track stats from the game over the session, i.e. stats that don't reset when a new board object is created.</p>
  
  <p>I have a <code>TicTacToeComponent</code> that creates a new board and that's about it, and the <code>TicTacToeBoard</code> object has all the fields and logic for the game. The user can create a new board using a button tied to <code>newGame()</code> in <code>TicTacToeComponent</code> or of course a new board is created when you load the page. Obviously tracking stats in the board object won't make sense. I was thinking a session object that creates each game is best, but I'm not sure how I would be able to inject the stats from that into the <code>TicTacToeComponent</code> template... How can I track stats over a whole user session which might have multiple games created? Is this some kind of observable pattern? How can I implement this?</p>
  
  <pre><code>app
   |--tic-tac-toe
   |        |--tic-tac-toe.component.* (imports and instantiates board)
   |
   |--app.component.* (routes to welcome screen and t-t-t.component
   |
   |--tic-tac-toe-board.ts (board class, probably should be moved)
  </code></pre>
  
  <p>Solving this might also allow me to keep a game even when routing to another page and back. </p>
  
  <p><a href="https://github.com/mosherc/tic-tac-toe" rel="nofollow noreferrer">Source code</a></p>