Skip to content

Instantly share code, notes, and snippets.

Avatar

NullVoxPopuli

View GitHub Profile
@NullVoxPopuli
NullVoxPopuli / controllers.application\.js
Last active Aug 12, 2021
QP-Only Transition Bug Reproduction
View controllers.application\.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
queryParams = ['test'];
appName = 'Ember Twiddle';
@service router;
View controllers.application\.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
@tracked records = freshArray();
@action addFirst() {
log('add:first, expect one each log');
this.records = [{ id: this.records.length + 1 }, ...this.records ];
View components.checkbox-demo\.hbs
<h2>Checkbox</h2>
<input
checked={{this.value}}
type='checkbox'
{{on 'input' this.handleInput}}
{{on 'change' this.handleChange}}
>
<button {{on 'click' this.changeValue}}>Change the value externally</button>
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View controllers.application\.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
@service ajax;
appName = 'Ember Twiddle';
@action
async doSomething() {
@NullVoxPopuli
NullVoxPopuli / components.my-repository\.js
Last active May 28, 2021
Convert to derived data - new
View components.my-repository\.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class MyRepository extends Component {
@tracked showDetailVisible = false;
@tracked branches = '';
@action
async showDetail(name, organizationName, token) {
@NullVoxPopuli
NullVoxPopuli / components.my-repository\.js
Last active May 28, 2021
Convert to derived data - Original
View components.my-repository\.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class MyRepository extends Component {
@tracked showDetailVisible = false;
@tracked branches = '';
@action
async showDetail(name, organizationName, token) {
View components.app\.js
import Component from '@glimmer/component';
export default class extends Component {
}
@NullVoxPopuli
NullVoxPopuli / controllers.application\.js
Last active Apr 16, 2021
tracked-built-ins array demo
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from 'tracked-built-ins';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
woo = tracked([0, 1, 2, 3]);
@action