Created
February 25, 2014 16:56
-
-
Save michael-benin-CN/9212981 to your computer and use it in GitHub Desktop.
This is an example of bind vs self scoping. Which do you prefer?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init: function () { | |
setInterval(function () { | |
ajax('/last-modified', { | |
cache: false | |
}).then(function (data) { | |
if (moment(this.get('date')).isBefore(data.modified)) { | |
this.set('appUpdated', true); | |
} | |
}.bind(this), function (e) { | |
//console.log(e); | |
}.bind(this)); | |
}.bind(this), (this.get('seconds') * 1000)); | |
} | |
init: function () { | |
var self = this; | |
setInterval(function () { | |
ajax('/last-modified', { | |
cache: false | |
}).then(function (data) { | |
if (moment(self.get('date')).isBefore(data.modified)) { | |
self.set('appUpdated', true); | |
} | |
}, function (e) { | |
//console.log(e); | |
}); | |
}, (self.get('seconds') * 1000)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment