onStop sync/async mix
January 24, 2019 at 2:52pmonStop sync/async mix
January 24, 2019 at 2:52pm (Edited 4 years ago)The frontend/backend-contribution indicates that onStop is synchronous. However, WorkspaceServer's onStop calls an asynchronous method to set the last used workspace.
Is there any garantee that the last workspace used will actually get written out to the filesystem, or is this a "fingers-crossed it finishes in time" situation?
I am curious if there is a way to finish asynchronous or long-running operations called within onStop. I want to store some data (which is an asynchronous operation) which can happen after the window closes, but before Theia exits. Is it possible to do this in Theia, Electron specifically?
January 24, 2019 at 3:52pm
For the frontend we are relying on
unload
event. See https://github.com/theia-ide/theia/blob/master/packages/core/src/browser/frontend-application.ts#L159It doesn't run async afterwards.
January 25, 2019 at 8:00am
There is
onWillStop
callback in which you can notify a user about unsaved changes: https://github.com/theia-ide/theia/blob/5156023a4b0c590b40485f82d5c798c6ef6f8dec/packages/core/src/browser/frontend-application.ts#L45-L50and prevent closing