mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add Emitter.clear() and DisposableStatic.isDisposable() (#12472)
This commit is contained in:
parent
4d7168f75d
commit
efb5680468
@ -24,6 +24,7 @@ class User {
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.emitter.clear();
|
||||
this.emitter.dispose();
|
||||
}
|
||||
}
|
||||
@ -39,6 +40,7 @@ var user = new User();
|
||||
var subscription = user.onDidChangeName((name: string) => {
|
||||
console.log('User name change to: ' + name);
|
||||
});
|
||||
if(Disposable.isDisposable(subscription)) {}
|
||||
subscription.dispose();
|
||||
|
||||
// CompositeDisposable
|
||||
|
||||
11
event-kit/index.d.ts
vendored
11
event-kit/index.d.ts
vendored
@ -14,6 +14,10 @@ declare namespace AtomEventKit {
|
||||
interface DisposableStatic {
|
||||
prototype: Disposable;
|
||||
new (disposalAction: Function): Disposable;
|
||||
/**
|
||||
* Ensure that Object correctly implements the Disposable.
|
||||
*/
|
||||
isDisposable(object: Object): boolean;
|
||||
}
|
||||
|
||||
/** Instance side of the Disposable class. */
|
||||
@ -59,6 +63,13 @@ declare namespace AtomEventKit {
|
||||
isDisposed: boolean;
|
||||
|
||||
constructor: EmitterStatic;
|
||||
/**
|
||||
* Clear out any existing subscribers.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Unsubscribe all handlers.
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* Registers a handler to be invoked whenever the given event is emitted.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user