Class ArrayProxy

public
Extends: EmberObject
Uses: MutableArray
Defined in: packages/ember-runtime/lib/system/array_proxy.js:33
Module: @ember/array
import ArrayProxy from '@ember/array/proxy';

An ArrayProxy wraps any other object that implements Ember.Array and/or Ember.MutableArray, forwarding all requests. This makes it very useful for a number of binding use cases or other cases where being able to swap out the underlying array is useful.

A simple example of usage:

let pets = ['dog', 'cat', 'fish'];
let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) });

ap.get('firstObject');                        // 'dog'
ap.set('content', ['amoeba', 'paramecium']);
ap.get('firstObject');                        // 'amoeba'

This class can also be useful as a layer to transform the contents of an array, as they are accessed. This can be done by overriding objectAtContent:

let pets = ['dog', 'cat', 'fish'];
let ap = Ember.ArrayProxy.create({
    content: Ember.A(pets),
    objectAtContent: function(idx) {
        return this.get('content').objectAt(idx).toUpperCase();
    }
});

ap.get('firstObject'); // . 'DOG'

Methods

Properties

Events

No documented items

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/classes/ArrayProxy