Instantly share code, notes, and snippets.

View controllers.application.js
import Controller from '@ember/controller';
import { reads } from '@ember/object/computed';
export default Controller.extend({
queryParams: ['theObject'],
actions: {
updateTheObject() {
this.set('theObject', { appName: this.appName });
}
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View adapters.application.js
import JSONAPIAdapter from 'ember-data/adapters/json-api';
export default JSONAPIAdapter.extend({
namespace: '/api'
});
View components.date-time-adjuster.js
import Component from '@ember/component';
import { computed } from '@ember/object';
import { not } from '@ember/object/computed';
import moment from 'moment';
function validatedMoment(value, format) {
return value ? moment(value, format, true) : moment.invalid();
}
export default Ember.Component.extend({
View components.card-face.js
import Component from '@ember/component';
import { computed } from '@ember/object';
import { reads } from '@ember/object/computed';
import { htmlSafe } from '@ember/string';
import { SUITS, JOKER } from '../libs/card';
const SUIT_MAP = Object.freeze({
[SUITS.CLUBS]: 'clubs',
[SUITS.DIAMONDS]: 'diams',
[SUITS.HEARTS]: 'hearts',
View components.json-output.js
import Component from '@ember/component';
import { computed } from '@ember/object';
export default Component.extend({
tagName: 'pre',
classNames: ['json-output'],
output: computed('json', function() {
return JSON.stringify(this.json, null, 2);
})
View controllers.application.js
import Controller from '@ember/controller';
import { computed } from '@ember/object';
export default Controller.extend({
appName: 'Ember Twiddle',
isEvenLength: computed('appName', function() {
return this.appName.length % 2 === 0;
}),
View controllers.application.js
import Ember from 'ember';
import { reads } from '@ember/object/computed';
export default Ember.Controller.extend({
people: reads('model')
});
View components.big-text.js
import Component from '@ember/component';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';
import { scheduleOnce } from '@ember/runloop';
import FontResizer from '../libs/font-resizer';
export default Component.extend({
classNames: ['big-text'],
attributeBindings: ['style'],
View components.link-to.js