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
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
8
9
class CustomSelect extends Component {
  constructor(...args) {
    super(...args);

    // 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.