Skip to content

Commit a72ff3f

Browse files
committed
Fix implementation
1 parent 11720b4 commit a72ff3f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

Source/resilience/Cancellation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ import { Observable, NEVER } from 'rxjs';
77
* Represents a possible cancellation.
88
*/
99
export class Cancellation extends Observable<void> {
10+
/**
11+
* Creates a new instance of the {@link Cancellation} class.
12+
* @param {Observable<void>} source - The source observable that indicates when a cancellation has occured.
13+
*/
14+
constructor(source: Observable<void>) {
15+
super(source.subscribe);
16+
}
1017

1118
/**
1219
* Default cancellation, which is never.
1320
*/
14-
static default: Cancellation = NEVER;
21+
static default: Cancellation = new Cancellation(NEVER);
1522
}

Source/resilience/CancellationSource.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Cancellation } from './Cancellation';
88
* Represents the source of a {@link Cancellation}.
99
*/
1010
export class CancellationSource {
11-
private _subject: Subject<void>;
11+
private readonly _subject: Subject<void>;
1212

1313
/**
1414
* Initializes a new instance of {@link CancellationSource}.
@@ -19,6 +19,7 @@ export class CancellationSource {
1919
for (const source of sources) {
2020
source.subscribe(this._subject);
2121
}
22+
this.cancellation = new Cancellation(this._subject);
2223
}
2324

2425
/**
@@ -31,9 +32,7 @@ export class CancellationSource {
3132
/**
3233
* Gets the cancellation subject.
3334
*/
34-
get cancellation(): Cancellation {
35-
return this._subject;
36-
}
35+
readonly cancellation: Cancellation;
3736

3837
/**
3938
* Get whether or not the {@link CancellationSource} is cancelled.

0 commit comments

Comments
 (0)