Skip to content

Instantly share code, notes, and snippets.

@jlami
jlami / controllers.application\.js
Last active April 14, 2020 15:20
ember-int-htmlattr-delay
import Controller from '@ember/controller';
import {action} from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@service intl;
date = new Date();
@jlami
jlami / controllers.application.js
Last active March 22, 2019 10:47
Array of Arrays
import Ember from 'ember';
let Container = Ember.Object.extend({
init() {
this.set('items', []);
},
comp2: Ember.computed('[email protected]', function() {
console.log('2deep');
//console.log(this.items.mapBy('j'));
return Math.random();
@jlami
jlami / adapters.application.js
Last active September 7, 2018 02:39
Ember-data promise proxy bug
import DS from 'ember-data';
import { Promise as EmberPromise } from 'rsvp';
export default DS.Adapter.extend({
deleteRecord() {
console.log('deleting', arguments);
return EmberPromise.resolve();
},
});
@jlami
jlami / controllers.application.js
Last active November 14, 2017 17:25
ember-bug-multi-brace-plus-arrayproxy
import Ember from 'ember';
export default Ember.Controller.extend({
items: [
{ id: 1, test: true, cat: 1},
{ id: 2, test: true, cat: 2},
{ id: 3, test: true, cat: 3},
{ id: 4, test: true, cat: 4},
{ id: 5, test: false, cat: 1},
{ id: 6, test: false, cat: 2},
@jlami
jlami / controllers.application.js
Last active September 28, 2017 20:46
Action promise ignored
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
moveOn() {
return new Ember.RSVP.Promise((resolve, reject) => {
//should work with any async callback
setTimeout(resolve, 1000);
@jlami
jlami / controllers.application.js
Last active September 20, 2017 08:44
filterBy @each bug
import Ember from 'ember';
import computed from 'ember-macro-helpers/computed';
import raw from 'ember-macro-helpers/raw';
import { filterBy, first } from 'ember-awesome-macros/array';
export default Ember.Controller.extend({
data: [
Ember.Object.create({ filter: 0, label: '1' }),
Ember.Object.create({ filter: 1, label: '2' }),
Ember.Object.create({ filter: 1, label: '3' }),
@jlami
jlami / adapters.application.js
Created July 27, 2017 13:58
delete-after-reload-error
import Adapter from "ember-data/adapters/json-api";
export default Adapter.extend();
@jlami
jlami / models.author.js
Created May 9, 2017 12:25
unloadRecord-breaks-2.13
import Ember from "ember";
import DS from "ember-data";
const {attr, hasMany} = DS;
export default DS.Model.extend({
posts: hasMany('post'),
name: attr('string'),
test: Ember.computed('[email protected]', function() {
console.group();
@jlami
jlami / ember.computed.flattenArray.js
Created February 16, 2017 12:30 — forked from alexdiliberto/ember.computed.flattenArray.js
Ember.computed.flattenArray()
// ember-runtime/lib/computed/reduce_computed_macros.js
// Credit to Nopik via https://github.com/emberjs/ember.js/pull/3503
/*
var item1 = Ember.Object.create({
tags: [ 'important', 'bug', 'task' ],
});
var item2 = Ember.Object.create({
@jlami
jlami / controllers.application.js
Last active February 16, 2017 11:09
Ignored action on re-render?
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
//query: '',
clicked: false,
arr: Ember.computed('query', function() {
console.log('arr', this.get('query'));
let a = [];
if (this.get('query') !== undefined) {