Skip to content

Instantly share code, notes, and snippets.

@ssylvia
Last active August 4, 2017 17:36
Show Gist options
  • Save ssylvia/9064f5e7f0e5fc133c771a3385270d8f to your computer and use it in GitHub Desktop.
Save ssylvia/9064f5e7f0e5fc133c771a3385270d8f to your computer and use it in GitHub Desktop.
TestOverride
import Ember from 'ember';
const PersonArray = Ember.Object.extend({
shoppingList: ['eggs', 'cheese']
});
const a = PersonArray.create({
name: 'Stefan Penner',
addItem() {
this.get('shoppingList').pushObject('bacon');
}
});
const b = PersonArray.create({
name: 'Robert Jackson',
addItem() {
this.get('shoppingList').pushObject('sausage');
}
});
console.log(1,a.get('shoppingList'),b.get('shoppingList'));
a.addItem();
console.log(2,a.get('shoppingList'),b.get('shoppingList'));
b.addItem();
console.log(3,a.get('shoppingList'),b.get('shoppingList'));
const PersonFunc = Ember.Object.extend({
shoppingList: Ember.computed('name',function() {
return [this.get('name'), 'egg'];
})
});
const c = PersonFunc.create({
name: 'Stefan Penner',
addItem() {
this.get('shoppingList').pushObject('bacon');
}
});
const d = PersonFunc.create({
name: 'Robert Jackson',
addItem() {
this.get('shoppingList').pushObject('sausage');
}
});
console.log(4,c.get('shoppingList'),d.get('shoppingList'));
c.addItem();
console.log(5,c.get('shoppingList'),d.get('shoppingList'));
d.addItem();
console.log(6,c.get('shoppingList'),d.get('shoppingList'));
const PersonFuncInit = Ember.Object.extend({
init() {
this.set('shoppingList', Ember.computed('name',function() {
return [this.get('name'), 'egg'];
}));
}
});
const e = PersonFuncInit.create({
name: 'Stefan Penner',
addItem() {
this.get('shoppingList').pushObject('bacon');
}
});
const f = PersonFuncInit.create({
name: 'Robert Jackson',
addItem() {
this.get('shoppingList').pushObject('sausage');
}
});
console.log(7,e.get('shoppingList'),f.get('shoppingList'));
e.addItem();
console.log(8,e.get('shoppingList'),f.get('shoppingList'));
f.addItem();
console.log(9,e.get('shoppingList'),f.get('shoppingList'));
export default Ember.Controller.extend({});
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": true,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment