Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Thoburn runspired

View GitHub Profile
View components.tom-tom\.js
import Component from '@glimmer/component';
export default class extends Component {
constructor() {
super(...arguments);
let m = document.createElement('div');
m.className="tom-tom-map";
this.mapContainer = m;
this.map = null;
View controllers.application\.js
import Controller from '@ember/controller';
import EmberObject from '@ember/object';
import { on } from '@ember/object/evented';
const Thing = EmberObject.extend({
_onInit: on('init', function() { console.log('hi') }),
});
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@runspired
runspired / components.my-component\.js
Last active May 25, 2021
Curry Args to Component Helper
View components.my-component\.js
import Component from '@glimmer/component';
export default class extends Component {
}
View adapters.post.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'https://jsonplaceholder.typicode.com'
});
View controllers.application\.js
import Controller from '@ember/controller';
import {tracked} from '@glimmer/tracking'
import { isEmpty } from '@ember/utils';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked list = [
"Active Directory and Group Policy",
"Airwatch",
"Apple iOS Apps",
View components.my-component\.js
import Component from '@ember/component';
export default Component.extend({
names: [],
init(...args) {
this._super(...args);
this.names.push(this.elementId);
}
});
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { dependentKeyCompat } from '@ember/object/compat';
import { action } from '@ember/object';
class Record {
_currentState = { isNew: true }
@tracked _stateNotify = 0;
getState() {
View controllers.application\.js
import Controller from '@ember/controller';
import Paginated from '../paginated';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked pageIndex = 0;
data = Paginated.create();
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
let renderCount = 0;
function trackedWithCache(target, key, desc) {
let _v;
let d = tracked(target, key, desc);
return {
View adapters.application\.js
import JSONAPIAdapter from '@ember-data/adapters/json-api';
// ideally write entirely your own thing, but you can do this just as well extending an existing adapter
export default class Adapter extends JSONAPIAdapter {
async query(store, schema, query, recordArray, { adapterOptions }) {
if (adapterOptions.isRelationshipQuery) {
// tbh depending on this link in this situation is probably not the way
// to go. You probably want to construct the url yourself or access the full
// set of links and choose the right one.