Home Manual Reference Source Repository
import {BeforeDestroyEvent} from 'ug-layout/events/BeforeDestroyEvent'
public class | source

BeforeDestroyEvent

Extends:

Cancellable<T> → BeforeDestroyEvent

Event fired before an item is destroyed. Mostly used in a View. This event allows the user to cancel the destruction of a Renderable. For example, if a tab is closed this event will be fired and sent down the tree and subscribed to by a view. The view can perform an async clean up task or display a confirm to the user before actually destroying the Renderable.

See:

Example:

class MyView {
  ugOnBeforeDestroy(e: BeforeDestroyEvent): void {
    e.wait(async () => {
      const confirmed = await this.confirmClose();

      if (!confirmed) {
        e.cancel();
      }
    });
  }
}