Skip to content

Instantly share code, notes, and snippets.

@amk221
amk221 / adapters.my-model\.js
Last active October 24, 2024 11:29
model transforms
import RESTAdapter from 'ember-data/adapters/rest';
export default class MyModelAdapter extends RESTAdapter {
findRecord() {
return {
myModel: {
id: 1,
a: null,
b: '2024-10-24T01:02:03',
c: '2024-10-24T01:02:03',
@amk221
amk221 / adapters.bar\.js
Last active August 9, 2024 08:56
ed miranda
import RESTAdapter from '@ember-data/adapter/rest';
export default class extends RESTAdapter {}
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
export default class extends Controller {
// This is where Query Params need to be configured.
// queryParams = ['foo'];
@tracked foo;
}
@amk221
amk221 / controllers.application\.js
Last active February 22, 2024 09:29
route redirect model
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@amk221
amk221 / controllers.application\.js
Created January 12, 2024 20:23
transitionto as a replacement for refresh
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject } from '@ember/service';
export default class ApplicationController extends Controller {
@inject router;
@action
go() {
this.router.transitionTo('my-route2');
@amk221
amk221 / decorator.js
Last active December 20, 2023 09:23
Pagination
import { action } from '@ember/object';
export default function withPagination(Controller) {
return class extends Controller {
@action
previousPage() {
this.page--;
}
@action
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
object = {
'my.key': 'foo',
my: {
key: 'bar',
}
};
}
@amk221
amk221 / components.my-component\.js
Last active September 19, 2023 08:16
checked state
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class extends Component {
@tracked checked;
@action
uncheck() {
this.checked = false;