Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active December 21, 2015 22:29
Show Gist options
  • Save Chandler/6375929 to your computer and use it in GitHub Desktop.
Save Chandler/6375929 to your computer and use it in GitHub Desktop.
{{#if game.moreThanOnePlayer}}
  <span> it was true </span>
{{else}}
App.Game = DS.Model.extend
  players: DS.hasMany 'App.Player'
  moreThanOnePlayer: (->
  
    promise = @get('players') #triggers ajax call that returns a promise
    
    promise.then(
    (players) -> #promise success call back
      console.log players.length > 1 #=> this prints out the correct value
    )
    
    #but the return value of the function is still a promise, which always evaluates to true.
    return promise
  ).property('players')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment