[Solved] 'Dispose' events listeners that watched active editors that were 'destroyed'

Using as reference the gist from
https://gist.github.com/maxbrunsfeld/d3671eb644e54d251b43c0093a7fa466

Specifically the code:

const {CompositeDisposable} = require('atom')

module.exports = {
  activate () {
    this.subscriptions = new CompositeDisposable()

    this.subscriptions.add(atom.workspace.onDidAddTextEditor(editor => {
      const editorSubscriptions = new CompositeDisposable()

      editorSubscriptions.add(editor.onDidStopChanging(() => {
        console.log('Editor changed', editor)
      }))

      editorSubscriptions.add(editor.onDidDestroy(() => {
        editorSubscriptions.dispose()
        this.subscriptions.remove(editorSubscriptions)
      }))

      this.subscriptions.add(editorSubscriptions)
    }))
  },

  deactivate () {
    this.subscriptions.dispose()
  }
}

My project aim to use the event atom.workspace.observeTextEditors() in the same manner as above. That means the events associated with a specific editor should be disposed.

I doubt the method, as given above. Will a unique editorSubscription object be created for each editor that triggers the event? How do I test that this method works as expected?

The code mentioned above has been reworked.
My questions are now answered.

'use babel';

const {CompositeDisposable} = require('atom');

export default {

  subscriptions: null,

  activate () {
    this.subscriptions = new CompositeDisposable();

    this.subscriptions.add(atom.workspace.onDidAddTextEditor(event => {
      const editorSubscriptions = new CompositeDisposable();
      if ((editor = event.textEditor) == null) {
        return;
      };

      editorSubscriptions.add(editor.onDidStopChanging(() => {
        console.log('Editor changed', editor);
      }))

      editorSubscriptions.add(editor.onDidDestroy(() => {
        console.log(this.subscriptions);
        editorSubscriptions.dispose();
        this.subscriptions.remove(editorSubscriptions);
        x = (function () {console.log(this.subscriptions)}).bind(this)();
        setTimeout(x, 10);
      }))

      this.subscriptions.add(editorSubscriptions);
    }))
  },

  deactivate() {
    this.subscriptions.dispose();
  }

};