Tracking changes (save)

Im tracking documents that change (saved) in my extension.

My approach is to hook a callback for onDidAddTextEditor() and then use the onDidSave() of each text editor.

In Atom the workspace had global events/callbacks for these sort of events which made coding much easier.

Is there another way to track changes?

Example of Atom’s API:
observeTextEditors

You’re probably looking for onWillSave()

Edit:
Oh I might have misinterpreted your question… perhaps the Workspace global properties/methods might be what you’re looking for?

1 Like

I think observeTextEditors is analogous to Nova’s onDidAddTextEditor, which doesn’t really do what you describe in your first post. As far as I know, there’s no shorter way than

nova.workspace.onDidAddTextEditor(
    editor => editor.onDidSave(() => {
        // do something
    })
)

or

nova.workspace.onDidAddTextEditor(
    editor => editor.onWillSave(() => {
        // do something
    })
)

.

1 Like