Skip to content

Instantly share code, notes, and snippets.

@pswai
Created March 8, 2017 06:49
Show Gist options
  • Save pswai/1ee98cc80d6a66b5a765b896bfc7fde0 to your computer and use it in GitHub Desktop.
Save pswai/1ee98cc80d6a66b5a765b896bfc7fde0 to your computer and use it in GitHub Desktop.
ArrayProxy does not have `concat`
import Ember from 'ember';
export default Ember.Controller.extend({
proxy: Ember.computed(() => Ember.ArrayProxy.create({ content: [1, 2, 3] })),
concatProxy: Ember.computed('proxy', function () {
// Uncomment this and it breaks
// return this.get('proxy').concat([4, 5, ,6]);
return this.get('proxy');
}),
array: Ember.computed(() => [1, 2, 3]),
concatArray: Ember.computed('array', function () {
return this.get('array').concat([4, 5, ,6]);
}),
testing: 'lalala'
});
<div>
Array:
{{#each array as |item|}}
{{item}}
{{/each}}
</div>
<div>
ConcatArray:
{{#each concatArray as |item|}}
{{item}}
{{/each}}
</div>
<div>
Proxy:
{{#each proxy as |item|}}
{{item}}
{{/each}}
</div>
<div>
ConcatProxy:
{{#each concatProxy as |item|}}
{{item}}
{{/each}}
</div>
This won't be rendered properly: {{testing}}
{
"version": "0.11.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment