Remove binding and Ember.copy

I am running into an issue where I want to pass around an array and then clone all its attributes and ensure that nothing is bound to it.

But it doesn’t seem to be obvious. And I am trying to find a relevant code example that demonstrates the use of Ember.Copyable mixin.

App.MyComponent = Ember.Component.extend({
    collection: Ember.A([]),  
    actions: {
        shareCollection: function() {
          var boundCollection = this.get('collection');
          // how do I unbind and make a copy of boundCollection array regardless of what is inside it?
         var unboundCollection; // should be a deep copy of the bound collection object
         this.sendAction('share', unboundCollection); 
        },
    }
});

Looking for a generic example of the use of Ember.copy(array, deep=true);

Perhaps a functional JSBin example?

This seems like it should be obvious but not really finding useful documentation or examples.

@eccegordo did you every find a solution to your problem to get an unbound array?

I have not yet seem a clear example that shows the Ember copy and stuff. But I was able to partially solve my problem by manually looping over an array and copying the items and then use pushObject to populate the new array. But the binding stuff does get a little confusing if you are not careful.

Will try to post a JSBin of the concept and see if anyone else has a better idea on how to do it.

You can get an unbound array with a call to toArray(), can’t you? Or am I missing something obvious?

Do you want a deep clone of the array and its contents? That kind of depends on its contents, I think… if you have model objects in there, for example, you’re going to need to determine what to do with keys and associations, if you have them. :confused: