|
@@ -1,26 +0,0 @@
|
|
|
-import { isObservable, Observable, Observer, Subject } from "rxjs";
|
|
|
-
|
|
|
-function isRxObservable(value: any): value is Observable<any> {
|
|
|
- return isObservable(value);
|
|
|
-}
|
|
|
-function isRxObserver(value: any): value is Observer<any> {
|
|
|
- return (
|
|
|
- value &&
|
|
|
- typeof value === 'object' &&
|
|
|
- typeof value.next === 'function' &&
|
|
|
- typeof value.error === 'function' &&
|
|
|
- typeof value.complete === 'function'
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
-// Check specifically if the value is a Subject
|
|
|
-function isRxSubject(value: any): value is Subject<any> {
|
|
|
- return isRxObservable(value) && isRxObserver(value);
|
|
|
-}
|
|
|
-
|
|
|
-export function checkRxType(value: any): 'Subject' | 'Observable' | 'Observer' | 'Neither' {
|
|
|
- if (isRxSubject(value)) return 'Observer' // for now returns observer, because subject passes as Observable as well. Can modify at later date
|
|
|
- if (isRxObservable(value)) return 'Observable'
|
|
|
- if (isRxObserver(value)) return 'Observer'
|
|
|
- return 'Neither';
|
|
|
-}
|