Resetting a property containing an array in willDestroy does not work


Why can’t I reset a property containing an array in the willDestroy hook of an ember object instance?

jsfiddle example


You’ve been trolled by a long discussed issue:

The fix:

If you’re really after the shared instance of array across instances of this type, then: but it’s probably more appropriate to make it a class property to avoid confusion in the future. Something like:


Thanks for the link that issue makes sense, but why doesn’t the array get set in willDestroy? This seems like a bug, if I can set the property on init why not on destroy isn’t that the main use case for the willDestroy hook?


I’m not really sure why that is happening, but I’m curious what the usecase of changing a prop on an instance that is about to be destroyed? My guess is it’s a timing thing within the run loop.