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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
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
import Controller from '@ember/controller'; | |
import { getOwner } from '@ember/application'; | |
import { inject as service } from '@ember/service'; | |
import attr from 'ember-data/attr'; | |
const NEW_ATTRS = { | |
age: { kind: 'attribute', name: 'age', type: 'number', options: {} } | |
}; | |
function upgradeModelSchema(owner, type, newAttrs) { |
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
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
import { tracked } from '@glimmer/tracking'; | |
import { next } from '@ember/runloop'; | |
const createdAt = new Date().toUTCString(); | |
let inc = 0; | |
export default class ApplicationController extends Controller { | |
@service store; |
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
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
/* | |
{ | |
data: { | |
type: 'user', | |
id: '1', | |
attributes: { | |
name: 'Chris', |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
newlyCreated = [ | |
{ name: 'james' } | |
]; | |
source = [ |
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
import Controller from '@ember/controller'; | |
import { tracked } from '@glimmer/tracking'; | |
import { guidFor } from '@ember/object/internals'; | |
function inspect(target, key, descriptor) { | |
const { initializer } = descriptor; | |
descriptor.initializer = function $inspectInit() { | |
const value = initializer.call(this); | |
console.log(`[initialized] ${this.constructor.name}<${guidFor(this)}>.${key}`, value); | |
return value; |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
constructor() { | |
super(...arguments); | |
this.user = this.store.push({ | |
data: { | |
type: 'user', |
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
import Controller from '@ember/controller'; | |
import { A } from '@ember/array'; | |
const ArrayLike = { length: 0 }; | |
Object.defineProperty(ArrayLike, '[]', { | |
enumerable: true, | |
//configurable: false, | |
get() { | |
return 0; | |
}, |
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
const ArrayLike = { length: 0 }; | |
Object.defineProperty(ArrayLike.prototype, 'push', { | |
enumerable: true, | |
configurable: false, | |
get() { | |
return 0; | |
}, | |
set() { | |
throw new Error('Do Not Set'); | |
} |
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
function timedGet(selector) { let start = performance.now(); let all = document.querySelectorAll(selector); let end = performance.now(); return { start, end, all }; } | |
function iterateAll(selector, cb) { | |
let data = timedGet(selector); | |
for (let e of data.all) cb(e); | |
let end = performance.now(); | |
console.log({ start: data.start, iter: data.end, end, duration: end - data.start }) | |
} | |
seen2 = new Set(); iterateAll('*', (e) => seen2.add(e)); |
NewerOlder