How to launch a theia extension command

If we follow the basic hello world extension, notification is shown on user action (menu action). How to trigger a command onLoad or onUnload of theia frontend (editor)

Usecase:

  • Display a welcome / landing page display on first load

  • When user switches tab start a countdown to limit/scale down server to save cost

[original thread by Soumesh Banerjee]

FrontendApplicationContribution provides app lifecycle hooks: https://github.com/eclipse-theia/theia/blob/0c010984dc73cd642fc71c9ea8be13a7ea5800ec/packages/core/src/browser/frontend-application.ts#L32

i.e. async configure hook can block the shell loading

and then there is onWillStop and onStop

you cannot do any async code on stop even, it will be ignored by a browser

so fo the second case i guess you will need some kind of ping from the frontend

[Soumesh Banerjee]

Maybe beaconAPI would be helpful for the onWillStop and onStop events else PING-PONG mechanism works as well