Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 1.38 KB

how-to-prevent-view-destruction.md

File metadata and controls

36 lines (29 loc) · 1.38 KB

SCION Workbench

Overview Workbench Workbench Application Platform Contributing Changelog Sponsoring Links

How to prevent view destruction

In the view component, implement WbBeforeDestroy lifecycle hook. It is called when the component is about to be destroyed.

@Component({
  ...
  providers: [provideWorkbenchView(ViewComponent)]
})
export class ViewComponent implements WbBeforeDestroy {

  public wbBeforeDestroy(): Observable<boolean> | Promise<boolean> | boolean {
    // e.g., ask the user to close the view
  }
}

For non Angular applications, register a function via ViewService.

Platform.getService(ViewService).setDestroyNotifier(() => Observable<boolean> | Promise<boolean> | boolean {
  // e.g., ask the user to close the view
});