-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isObservable): Fix throwing error when testing isObservable(null)
- Loading branch information
Bryan Bonnet
committed
May 11, 2018
1 parent
dc66731
commit 9615ff3
Showing
2 changed files
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { Observable } from '../Observable'; | ||
import { ObservableInput } from '../types'; | ||
import { isObject } from './isObject'; | ||
import { isFunction } from './isFunction'; | ||
|
||
/** | ||
* Tests to see if the object is an RxJS {@link Observable} | ||
* @param obj the object to test | ||
*/ | ||
export function isObservable<T>(obj: any): obj is Observable<T> { | ||
return obj && obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'); | ||
return obj && obj instanceof Observable || | ||
(isObject(obj) || isFunction(obj)) ? (isFunction(obj.lift) && isFunction(obj.subscribe)) : false; | ||
} |