Skip to content

Instantly share code, notes, and snippets.

@JackieChiles
JackieChiles / components.my-component\.js
Last active December 30, 2020 15:47
Template Logic Avoid Example
import Component from '@glimmer/component';
export default class extends Component {
}
@JackieChiles
JackieChiles / components.my-component\.js
Created December 30, 2020 15:37
Component Logic Avoid Example
import Component from '@glimmer/component';
export default class extends Component {
get name() {
return `${this.args.person.firstName} ${this.args.person.lastName}`;
}
}
@JackieChiles
JackieChiles / components.my-component\.js
Created December 30, 2020 15:24
Component Logic Better Example
import Component from '@glimmer/component';
export default class extends Component {
}
@JackieChiles
JackieChiles / components.memory-tester\.js
Last active June 29, 2020 19:24
Each Memory Test 3.12
import Component from '@ember/component';
import { later } from '@ember/runloop';
import { A } from '@ember/array';
import { computed } from '@ember/object';
const numCycles = 100;
export default Component.extend({
init() {
this._super(...arguments);
import Component from '@glimmer/component';
import { later } from '@ember/runloop';
import { tracked } from '@glimmer/tracking';
import { A } from '@ember/array';
import { action } from '@ember/object';
export default class MemoryTester extends Component {
constructor(owner, args) {
super(owner, args);
this.initialHeapSize = this.snapshotHeapSize();
import Component from '@glimmer/component';
import { action, set } from '@ember/object';
import { A } from '@ember/array';
export default class extends Component {
rows = A([
{ name: 'a', age: 5 },
{ name: 'b', age: 10 },
{ name: 'c', age: 15 }
])
@JackieChiles
JackieChiles / components.my-component2\.js
Last active April 30, 2020 21:19
Octane Component Promise
import Component from '@glimmer/component';
export default class extends Component {
}
@JackieChiles
JackieChiles / components.my-component.js
Created July 23, 2018 13:53
Component Class Parameter
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['my-component']
});
@JackieChiles
JackieChiles / controllers.first-controller.js
Created June 26, 2018 18:50
Prototype Object Property
import Ember from 'ember';
import mixin from '../mixins/controller-mixin';
export default Ember.Controller.extend(mixin, {
text: 'First Controller',
onClick() {
this.set('mixinProp.value', 'aaa');
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
color: 'blue',
item: {
// I want this to be 'blue'
color: Ember.computed.alias('color')
}
});