Skip to content

Commit 5952037

Browse files
committed
Using lambdas
1 parent d2356da commit 5952037

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/CompositeDisposable.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/*---------------------------------------------------------------------------------------------
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
4-
*--------------------------------------------------------------------------------------------*/
5-
6-
import { Subscription } from "rxjs/Subscription";
7-
import Disposable, { IDisposable } from "./Disposable";
8-
9-
export default class CompositeDisposable extends Disposable {
10-
private disposables = new Subscription();
11-
12-
constructor (...disposables: IDisposable[]){
13-
super(() => this.disposables.unsubscribe());
14-
15-
for (const disposable of disposables) {
16-
if (disposable) {
17-
this.disposables.add(disposable.dispose);
18-
}
19-
else {
20-
throw new Error("null disposables are not supported");
21-
}
22-
}
23-
}
24-
25-
public add(disposable: IDisposable) {
26-
if (!disposable) {
27-
throw new Error("disposable cannot be null");
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { Subscription } from "rxjs/Subscription";
7+
import Disposable, { IDisposable } from "./Disposable";
8+
9+
export default class CompositeDisposable extends Disposable {
10+
private disposables = new Subscription();
11+
12+
constructor(...disposables: IDisposable[]) {
13+
super(() => this.disposables.unsubscribe());
14+
15+
for (const disposable of disposables) {
16+
if (disposable) {
17+
this.disposables.add(() => disposable.dispose());
18+
}
19+
else {
20+
throw new Error("null disposables are not supported");
21+
}
2822
}
29-
30-
this.disposables.add(disposable.dispose);
31-
}
23+
}
24+
25+
public add(disposable: IDisposable) {
26+
if (!disposable) {
27+
throw new Error("disposable cannot be null");
28+
}
29+
30+
this.disposables.add(() => disposable.dispose());
31+
}
3232
}

src/Disposable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class Disposable implements IDisposable {
1313
}
1414

1515
if (onDispose instanceof Subscription) {
16-
this.onDispose = () => onDispose.unsubscribe;
16+
this.onDispose = () => onDispose.unsubscribe();
1717
}
1818
else {
1919
this.onDispose = onDispose;

0 commit comments

Comments
 (0)