Skip to content

Instantly share code, notes, and snippets.

@ramonvictor
Last active May 8, 2016 17:46
Show Gist options
  • Save ramonvictor/e20894711a0524a6ce43cc4c2344dbbd to your computer and use it in GitHub Desktop.
Save ramonvictor/e20894711a0524a6ce43cc4c2344dbbd to your computer and use it in GitHub Desktop.
var store = require('./store');
var gridView = require('./grid-view');
TicTacToe.prototype.eventListeners = function() {
store.subscribe(this.render.bind(this));
};
TicTacToe.prototype.render = function(prevState, state) {
// You can even check whether new state is different
if (prevState.grid !== state.grid) {
this.gridView.render('grid', state.grid);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment