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 / controllers.application\.js
Created February 2, 2021 22:48
service helper lulz
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@chriskrycho
chriskrycho / testing-promises.js
Created January 31, 2021 18:02
Stepping through promise execution
function deferred() {
let deferred = { resolve: undefined, reject: undefined, promise: undefined };
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
<div class="container">
<Stoplight @colors={{this.colors}} @currentColor={{this.currentColor}} />
<button {{on "click" this.changeCurrentColor}}>Change</button>
<div>
<label>
<input
type="radio"
name="mode"
value="order"
checked={{eq this.mode "order"}}
@chriskrycho
chriskrycho / main.js
Created January 15, 2021 03:27
very stupid speed "test" because I was curious and bored
function random(max) {
return Math.round(Math.random() * max);
}
class Data {
stuff;
extraStuff;
whatever;
constructor(i) {
@chriskrycho
chriskrycho / args-demo.js
Created December 21, 2020 16:39
Demonstrating how args work in Glimmer components—with no Ember/Glimmer/autotracking in sight!
class Component {
#args;
get args() {
return this.#args;
}
constructor(args) {
this.#args = args;
}
}
<div style='border: 1px solid blue'>
<h2>child</h2>
<p><code>this.foo</code> is {{this.foo}}</p>
<label>
update child <input value={{this.foo}} {{on "input" this.updateFoo}}>
</label>
</div>
<p>Is it fun? {{if this.isFun "Yes!" "nooooo"}}</p>
import { helper } from '@ember/component/helper';
import { guidFor } from '@ember/object/internals';
export default helper(function uniqueId() {
return guidFor({});
});
<p>The id for this one is: {{this.id}}</p>