Skip to content

Instantly share code, notes, and snippets.

@amk221
Forked from krisselden/controllers.application.js
Last active July 12, 2016 14:39
Show Gist options
  • Save amk221/daec57f2d61263fee9eb8d64e0ed5f80 to your computer and use it in GitHub Desktop.
Save amk221/daec57f2d61263fee9eb8d64e0ed5f80 to your computer and use it in GitHub Desktop.
Glimmer 2
import { subscribe } from 'ember-instrumentation';
import { bind } from 'ember-runloop';
import EmberObject from 'ember-object';
export default EmberObject.extend({
init() {
this._super(...arguments);
subscribe('render.component', {
before: bind(this, '_before'),
after: bind(this, '_after')
});
},
_before(name, timestamp) {
return timestamp;
},
_after(name, end, payload, start) {
let time = (end - start) / 1000;
console.log(name, time);
}
});
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
console.time('my-component');
},
didInsertElement() {
this._super(...arguments);
console.timeEnd('my-component');
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Glimmer',
init() {
this._super(...arguments);
this.set('times', []);
for (let i = 0; i < 1000; i++) {
this.get('times').push(i);
}
}
});
import Ember from 'ember';
import config from './config/environment';
import Metrics from './_metrics';
// Ember.__loader.require('glimmer-util/lib/logger').default.level = 1;
// Metrics.create();
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
});
export default Router;
<h1>Welcome to {{appName}}</h1>
{{#each times as |time|}}
{{my-component time=time}}
{{/each}}
{{outlet}}
{
"version": "0.8.1",
"EmberENV": {
"FEATURES": {
"ember-glimmer": true
}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "canary",
"ember-template-compiler": "canary"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment