Function

import { unregisterDestructor } from '@ember/destroyable';
destroyable
Object|Function
the destroyable to unregister the destructor function from
destructor
Function
the destructor to remove from the destroyable

Receives a destroyable and a destructor function, and de-associates the destructor from the destroyable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { registerDestructor, unregisterDestructor } from '@ember/destroyable';

class Modal extends Component {
  @service modals;

  constructor() {
    this.modals.add(this);

    this.modalDestructor = registerDestructor(this, () => this.modals.remove(this));
  }

  @action pinModal() {
    unregisterDestructor(this, this.modalDestructor);
  }
}