Skip to content

Instantly share code, notes, and snippets.

View chriskrycho's full-sized avatar
🚀
Hire me! https://v5.chriskrycho.com/journal/next/role/

Chris Krycho chriskrycho

🚀
Hire me! https://v5.chriskrycho.com/journal/next/role/
View GitHub Profile
@chriskrycho
chriskrycho / Memory allocation profiling for Ember TS builds.md
Last active September 29, 2021 14:26
Memory Allocation Profiling for Ember + TS Builds

Memory Allocation Profiling for Ember + TS Builds

To get the info we need, you'll be building the app two different ways: the normal way you would with ember-cli-typescript installed, and then with it removed, doing a transpile-only (no type checking) build with Babel.

For the Babel-only build:

  • Remove ember-cli-typescript from your package.json and reinstall your dependencies.
  • Update your ember-cli-build.js following the instructions here.

Then run this test procedure for each of those:

import Controller from '@ember/controller';
import { inject } from '@ember/service';
export default class ApplicationController extends Controller {
@inject router;
get currentRoute() {
return this.router.currentRouteName;
}
}
@chriskrycho
chriskrycho / components.my-component\.js
Created August 16, 2021 21:17
example with terrible caching
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
function getAndClearFieldNamed(name, elements) {
const field = elements.namedItem(name);
if (!field) {
throw 'wat';
}
const value = field.value;
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@action submit(event) {
event.preventDefault();
const name = event.target.elements.namedItem('name').value;
alert(`Your name is ${name}`);
// do `fetch()` or something here!
}
{{#if this.hasBadge}}
<p>Count is: {{this.totalBadgeCount}}</p>
{{/if}}
<label style={{if @isFocused "background: green; color: white;"}}>
{{@name}}
<input id={{@name}} {{on "focus" @onFocusIn}}>
</label>
<button {{on "click" this.innerClick}} ...attributes>click it</button>
{{yield}}
<button {{on "click" this.tryToSetAnArg}}>
Try to set an arg
</button>
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}