Skip to content

Instantly share code, notes, and snippets.

View vitch's full-sized avatar

Kelvin Luck vitch

View GitHub Profile
import Controller from '@ember/controller';
import Ember from 'ember';
function foo(target, name, descriptor) {
console.log('foo', target, name, descriptor);
console.log( descriptor.initializer);
Object.defineProperty(target, name, {
configurable: false,
import Controller from '@ember/controller';
import EmberObject from '@ember/object';
import { action } from '@ember/object';
import { readOnly } from '@ember/object/computed';
class Buzz extends EmberObject {
bar = 0;
import Component from '@glimmer/component';
export default class extends Component {
get bob() {
return this.args.page.currentPage;
}
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
get foo() {
let span = document.createElement('span');
span.textContent = 'Fooooo';
return span;
}
@vitch
vitch / controllers.application\.js
Created October 2, 2020 22:58
get array access
import Controller from '@ember/controller';
import { get } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
foo = [{ bar: '1' }, { bar: '2'}, { bar: '3'}];
get fooFirstBar() {
return get(this, 'foo.firstObject.bar');
@vitch
vitch / components.inner-component\.js
Last active May 20, 2020 11:02
args / willDestroy
import Component from '@glimmer/component';
export default class extends Component {
willDestroy() {
console.log(this.args.data.name);
}
}
@vitch
vitch / controllers.application\.js
Last active May 6, 2020 10:43
octane + computed
import Controller from '@ember/controller';
import EmberObject, { action, computed } from '@ember/object';
let FakeModel = EmberObject.extend({
bar: 1,
foo: computed.readOnly('bar'),
});
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@vitch
vitch / components.rangeput\.js
Last active April 19, 2020 20:31
Splatting input type="range" value
import Component from '@glimmer/component';
export default class extends Component {
}
import Controller from '@ember/controller';
import EmberObject from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
get bob() {
return new Proxy({ name: 'foo' }, makeHandler('bob'));
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}