Skip to content

Instantly share code, notes, and snippets.

View mydea's full-sized avatar

Francesco Novy mydea

View GitHub Profile
@mydea
mydea / ember-strict-resolver-pods.ts
Created November 25, 2020 07:26
An extended strict resolver that works with pod routes/controllers/templates and nested co-located components.
import Resolver from 'ember-strict-resolver';
interface ModuleDefinition {
prefix: string;
type: string;
name: string;
}
export default class CustomStrictResolver extends Resolver {
legacyMappings: { [key: string]: string } = {
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class Application extends Controller {
@tracked size = {
height: 'unknown',
width: 'unknown',
};
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
export default class extends Component {
@tracked chartData;
constructor() {
super(...arguments);
this.updateChartData();
import Controller from '@ember/controller';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
export default class ApplicationController extends Controller {
@tracked items;
@action
updateItems(event) {
let count = event.target.value;
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@mydea
mydea / controllers.application.js
Last active April 15, 2019 12:52
EmberError vs. native Error
import Ember from 'ember';
import EmberError from '@ember/error';
const NativeError = Error;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
emberError: Ember.computed(function() {
return new AdapterError('test');
@mydea
mydea / controllers.application.js
Created April 12, 2019 08:19
overwrite-volatile-cp
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
raven: Ember.inject.service()
});
import JSONAPIAdapter from 'ember-data/adapters/json-api';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';
export default JSONAPIAdapter.extend(AdapterFetch, {
ajax() {
let promise = this._super(...arguments);
promise.finally(() => console.log('done'));
@mydea
mydea / components.test-component.js
Last active February 20, 2019 15:11
Angle bracket vs. Curly brace values
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
value: 'default value'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});