core-api: updated Observable type to support interop

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-05-17 13:19:22 +02:00
parent e3f441e1db
commit e6f0180242
3 changed files with 16 additions and 2 deletions
+8
View File
@@ -53,6 +53,10 @@ export class PublishSubject<T>
ZenObservable.SubscriptionObserver<T>
>();
[Symbol.observable]() {
return this;
}
get closed() {
return this.isClosed;
}
@@ -148,6 +152,10 @@ export class BehaviorSubject<T>
ZenObservable.SubscriptionObserver<T>
>();
[Symbol.observable]() {
return this;
}
get closed() {
return this.isClosed;
}
+4 -2
View File
@@ -39,7 +39,7 @@ export type Subscription = {
/**
* Value indicating whether the subscription is closed.
*/
readonly closed: Boolean;
readonly closed: boolean;
};
/**
@@ -51,12 +51,14 @@ export type Subscription = {
* using many different observable implementations, such as zen-observable or RxJS 5.
*/
export type Observable<T> = {
[Symbol.observable](): Observable<T>;
/**
* Subscribes to this observable to start receiving new values.
*/
subscribe(observer: Observer<T>): Subscription;
subscribe(
onNext: (value: T) => void,
onNext?: (value: T) => void,
onError?: (error: Error) => void,
onComplete?: () => void,
): Subscription;
@@ -32,6 +32,10 @@ type Waiter = {
const nullObservable = {
subscribe: () => ({ unsubscribe: () => {}, closed: true }),
[Symbol.observable]() {
return this;
},
};
export class MockErrorApi implements ErrorApi {