Spectrum is now read-only. Learn more about the decision in our official announcement.


Eclipse Theia - Cloud & Desktop IDE


Trigger event in my extension on save editor

August 7, 2019 at 4:38pm

Trigger event in my extension on save editor

August 7, 2019 at 4:38pm
I would like to trigger an event from my extension when the save event happens. Is there any way to bind to this?

August 8, 2019 at 7:23am
Hi, for any editor or for a particular?
In Theia an editor is backed up by a model, the same model can be used by many different widgets.
So one saves not an editor, but an underlying model.
it allows you to listen to save events directly on the model.
It's important to release a reference when you don't need it anymore, otherwise a model will hang in the memory forever.

August 11, 2019 at 1:11pm
Thank you very much Anton! It's for any editor. I am going to try this out now.

August 26, 2019 at 11:56am
It worked well to bind to a Monaco editor:
export class MyWidget extends ReactWidget {
protected readonly workspaceService: WorkspaceService;
protected readonly MonacoWorkspace: MonacoWorkspace;
protected async init(): Promise<void> {
onWorkspaceSave(): void {
this.MonacoWorkspace.onWillSaveTextDocument(event => {
saveSpreadsheet = () => {
socket.emit('save', {});
However, now I need to change it to capture any save event (even when no Monaco editor is open). I looked at the second link you shared but wasn't able to figure out how to approach it. Would you be willing to give me more guidance?
Do you mean when no your widget is opened?
You can create a frontend application contribution which listens to all changes. It gets initialized on the frontend app start up.
Exactly, when my widget is open I want to listen to all changes. Any examples of a frontend application contribution? If not, I'll happily figure it out.

August 27, 2019 at 6:52am