Why can’t I reset a property containing an array in the willDestroy hook of an ember object instance?
You’ve been trolled by a long discussed issue: https://github.com/emberjs/ember.js/issues/462
The fix: Edit fiddle - JSFiddle - Code Playground
If you’re really after the shared instance of array across instances of this type, then: Edit fiddle - JSFiddle - Code Playground but it’s probably more appropriate to make it a class property to avoid confusion in the future. Something like: Edit fiddle - JSFiddle - Code Playground
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.