Imagine I create an ember object, then add it to an arbitrary unknown number of array controllers. Is there a simple way of destroying the object so that all the array controllers get notified and remove it?
destroy from Ember.CoreObject doesn’t seem to notify the collections that their objects have been destroyed, or the collections don’t remove their objects. I’m not even sure if they’re meant to or not.
The easiest way that I can think of is adding an observer on the object’s
isDestroyedproperty. That way when you destroy something and that property becomestrueyou can run whatever code you need to.See this jsfiddle: http://jsfiddle.net/ud3323/FSCyF/
Code: