-
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(Observer): fix typing to allow observation via partial observable…
…s with PartialObservable<T> - Observer<T> is the "full" observer interface - PartialObserver<T> is any object with at least one method of the Observer interface - Updates subscribe signature and Notification signatures to use PartialObserver instead of Observer Related #1260
- Loading branch information
Showing
8 changed files
with
64 additions
and
41 deletions.
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
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
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
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,19 +1,19 @@ | ||
import {Observer} from '../Observer'; | ||
import {PartialObserver} from '../Observer'; | ||
import {Subscriber} from '../Subscriber'; | ||
import {rxSubscriber} from '../symbol/rxSubscriber'; | ||
|
||
export function toSubscriber<T>( | ||
next?: Observer<T> | ((value: T) => void), | ||
nextOrObserver?: PartialObserver<T> | ((value: T) => void), | ||
error?: (error: any) => void, | ||
complete?: () => void): Subscriber<T> { | ||
|
||
if (next && typeof next === 'object') { | ||
if (next instanceof Subscriber) { | ||
return (<Subscriber<T>> next); | ||
} else if (typeof next[rxSubscriber] === 'function') { | ||
return next[rxSubscriber](); | ||
if (nextOrObserver && typeof nextOrObserver === 'object') { | ||
if (nextOrObserver instanceof Subscriber) { | ||
return (<Subscriber<T>> nextOrObserver); | ||
} else if (typeof nextOrObserver[rxSubscriber] === 'function') { | ||
return nextOrObserver[rxSubscriber](); | ||
} | ||
} | ||
|
||
return new Subscriber(next, error, complete); | ||
return new Subscriber(nextOrObserver, error, complete); | ||
} |