Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Created April 24, 2013 20:15
Show Gist options
  • Save dealingwith/5455201 to your computer and use it in GitHub Desktop.
Save dealingwith/5455201 to your computer and use it in GitHub Desktop.
modelLoadedCount: 0,
incrementAndCheckModelLoadedCount: function() {
this.modelLoadedCount++;
// do this better than hardcoding the count.
// maybe store models in an object or array and do a count?
// i don't like that idea any better than this at the moment
if (this.modelLoadedCount === 2) {
this.allModelsLoaded();
}
},
initialize: function() {
Game.player = new Game.Player;
Game.property = new Game.Property;
Game.player.on('loaded', _.bind(this.playerModelLoaded, this));
Game.property.on('loaded', _.bind(this.propertyModelLoaded, this));
},
render: function() {
FB.getLoginStatus(_.bind(this.loginCallback, this));
return this;
},
playerModelLoaded: function() {
this.incrementAndCheckModelLoadedCount();
// Set up subviews, get data
this.subViews.profileView = new Profile.View;
this.subViews.leaderboardView = new Leaderboard.View;
this.subViews.rateView = new Rate.View;
this.subViews.reviewView = new Review.View;
this.subViews.followView = new Follow.View;
Game.property.getPropertyDetails();
},
propertyModelLoaded: function() {
this.incrementAndCheckModelLoadedCount();
this.subViews.prizesView = new Prizes.View;
},
allModelsLoaded: function() {
this.subViews.shareView = new Share.View;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment