Skip to content

Instantly share code, notes, and snippets.

View buschtoens's full-sized avatar
🏳️‍🌈
Open Source

Jan Buschtöns buschtoens

🏳️‍🌈
Open Source
View GitHub Profile
import Controller from '@ember/controller';
import { action } from "@ember/object";
import { tracked } from "@glimmer/tracking";
import { schedule } from "@ember/runloop";
export default class ApplicationController extends Controller {
name = "";
@tracked nameSetInValidateName = "";
@tracked error = "Name must be at least 3 charaters";

Keybase proof

I hereby claim:

  • I am buschtoens on github.
  • I am buschtoens (https://keybase.io/buschtoens) on keybase.
  • I have a public key ASDgHF9u8DjxMiiPVx9mRp4ELKIbNWY1cjqihSn-HH4Lpgo

To claim this, I am signing this object:

import Route from '@ember/routing/route';
export default Route.extend({
model() {
return new Promise(resolve => setTimeout(resolve, 1000);
}
});
import Controller from '@ember/controller';
import { htmlSafe } from '@ember/string';
export default class ApplicationController extends Controller {
someElement = (() => {
const el = document.createElement('button');
el.setAttribute('type', 'button');
el.textContent = 'I am a real element.';
return el;
})();
@buschtoens
buschtoens / controllers.application\.js
Last active September 23, 2020 23:10
Tracking Mount Probe
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action, notifyPropertyChange } from '@ember/object';
import { next } from '@ember/runloop';
class ProbeCell {
constructor(name, pushLogEntry) {
this.name = name;
this.pushLogEntry = pushLogEntry;
}
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked counter = 0;
@action
import { addListener, trigger, removeListener } from './events';
import type { EVENTS } from './events';
class Foo {
declare [EVENTS]: {
bar(a: boolean, b: string, c: number): void;
qux(): void;
};
}
/**
* Big thanks to @dfreeman (Dan Freeman) for this!
*
* @see https://discordapp.com/channels/480462759797063690/484421406659182603/694852926572593253
*/
/**
* Retrieves the type of a type guard function.
* Like `ReturnType<T>`, but for type guard functions.
*
@buschtoens
buschtoens / controllers.application\.js
Last active March 5, 2020 10:34
No Service Base Class
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
@service foo;
}
@buschtoens
buschtoens / possible-today.ts
Last active December 23, 2019 16:14
Different potential solutions for templateless & renderless "provider" components
import Component from '@glimmer/component';
import { setComponentTemplate } from '@ember/component';
import { action } from '@ember/object';
import { hbs } from 'ember-cli-htmlbars';
export default setComponentTemplate(
hbs`
{{~yield
(hash
user=this.user