55'use strict' ;
66
77import { TPromise } from 'vs/base/common/winjs.base' ;
8- import { EventEmitter } from 'vs/base/common/eventEmitter' ;
98import Event , { Emitter } from 'vs/base/common/event' ;
109import types = require( 'vs/base/common/types' ) ;
1110import URI from 'vs/base/common/uri' ;
@@ -120,16 +119,16 @@ export interface IEditorInputFactory {
120119 * Editor inputs are lightweight objects that can be passed to the workbench API to open inside the editor part.
121120 * Each editor input is mapped to an editor that is capable of opening it through the Platform facade.
122121 */
123- export abstract class EditorInput extends EventEmitter implements IEditorInput {
124-
122+ export abstract class EditorInput implements IEditorInput {
123+ private _onDispose : Emitter < void > ;
125124 protected _onDidChangeDirty : Emitter < void > ;
126-
125+
127126 private disposed : boolean ;
128127
129128 constructor ( ) {
130- super ( ) ;
131-
132129 this . _onDidChangeDirty = new Emitter < void > ( ) ;
130+ this . _onDispose = new Emitter < void > ( ) ;
131+
133132 this . disposed = false ;
134133 }
135134
@@ -140,6 +139,13 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput {
140139 return this . _onDidChangeDirty . event ;
141140 }
142141
142+ /**
143+ * Fired when the model gets disposed.
144+ */
145+ public get onDispose ( ) : Event < void > {
146+ return this . _onDispose . event ;
147+ }
148+
143149 /**
144150 * Returns the name of this input that can be shown to the user. Examples include showing the name of the input
145151 * above the editor area when the input is shown.
@@ -237,11 +243,11 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput {
237243 * resolving the editor input.
238244 */
239245 public dispose ( ) : void {
240- this . _onDidChangeDirty . dispose ( ) ;
241246 this . disposed = true ;
242- this . emit ( 'dispose' ) ;
247+ this . _onDispose . fire ( ) ;
243248
244- super . dispose ( ) ;
249+ this . _onDidChangeDirty . dispose ( ) ;
250+ this . _onDispose . dispose ( ) ;
245251 }
246252
247253 /**
@@ -399,7 +405,19 @@ export interface ITextEditorModel extends IEditorModel {
399405 * connects to the disk to retrieve content and may allow for saving it back or reverting it. Editor models
400406 * are typically cached for some while because they are expensive to construct.
401407 */
402- export class EditorModel extends EventEmitter implements IEditorModel {
408+ export class EditorModel implements IEditorModel {
409+ private _onDispose : Emitter < void > ;
410+
411+ constructor ( ) {
412+ this . _onDispose = new Emitter < void > ( ) ;
413+ }
414+
415+ /**
416+ * Fired when the model gets disposed.
417+ */
418+ public get onDispose ( ) : Event < void > {
419+ return this . _onDispose . event ;
420+ }
403421
404422 /**
405423 * Causes this model to load returning a promise when loading is completed.
@@ -419,9 +437,8 @@ export class EditorModel extends EventEmitter implements IEditorModel {
419437 * Subclasses should implement to free resources that have been claimed through loading.
420438 */
421439 public dispose ( ) : void {
422- this . emit ( 'dispose' ) ;
423-
424- super . dispose ( ) ;
440+ this . _onDispose . fire ( ) ;
441+ this . _onDispose . dispose ( ) ;
425442 }
426443}
427444
0 commit comments