Function

import { associateDestroyableChild } from '@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.

1
2
3
4
5
6
7
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.