Function

associateDestroyableChild (parent, child, destructor) Object|Function public

Module: @ember/destroyable
parent
Object|Function
the destroyable to entangle the child destroyables lifetime with
child
Object|Function
the destroyable to be entangled with the parents lifetime
destructor
Function
the destructor to run when the destroyable object is destroyed
returns
Object|Function
the child argument

This function is used to associate a destroyable object with a parent. When the parent is destroyed, all registered children will also be destroyed.

class CustomSelect extends Component {
  constructor() {
    // obj is now a child of the component. When the component is destroyed,
    // obj will also be destroyed, and have all of its destructors triggered.
    this.obj = associateDestroyableChild(this, {});
  }
}

Returns the associated child for convenience.

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/3.25/functions/@ember%2Fdestroyable/associateDestroyableChild