forked from mystiq/hydrogen-web
Add types to disposeValue
This commit is contained in:
parent
7772643b0d
commit
dd74ed1957
1 changed files with 5 additions and 4 deletions
|
@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
function disposeValue(value) {
|
||||
type func = () => void;
|
||||
type Disposable = { dispose: func; [key: string]: any } | func;
|
||||
|
||||
function disposeValue(value: Disposable): void {
|
||||
if (typeof value === "function") {
|
||||
value();
|
||||
} else {
|
||||
|
@ -27,9 +30,7 @@ function isDisposable(value) {
|
|||
}
|
||||
|
||||
export class Disposables {
|
||||
constructor() {
|
||||
this._disposables = [];
|
||||
}
|
||||
private readonly _disposables = [];
|
||||
|
||||
track(disposable) {
|
||||
if (!isDisposable(disposable)) {
|
||||
|
|
Loading…
Reference in a new issue