Skip to content

Instantly share code, notes, and snippets.

Created September 3, 2013 21:24
Show Gist options
  • Save anonymous/6429814 to your computer and use it in GitHub Desktop.
Save anonymous/6429814 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
</head>
<body>
<script type="text/x-handlebars">
Count is {{count}}
</script>
</body>
</html>
App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
count: 0,
incrementCount: function() {
this.incrementProperty('count');
// Ember.run.later is Ember setTimeout wrapper:
// In 1000ms, call this.incrementCount(),
// safely nested in a run loop.
// Note that Ember is badass enough that
// strictly speaking you don't need all callbacks
// to take place in a run loop, but it's a good
// habit to get into as it can avoid "autoruns"
// which might lead to some non-determinism
// and performance issues in complex apps.
// Plus being able to pass in the `this` context
// is nice.
Ember.run.later(this, 'incrementCount', 1000);
}.on('init')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment