-
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.
refactor(mergeMap/switchMap): add handling for different inner return…
… types - support promise - support array - support iterable - support observable (lowercase o) - support Observable
- Loading branch information
Showing
8 changed files
with
242 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Subscriber from './Subscriber'; | ||
import Observer from './Observer'; | ||
import OuterSubscriber from './OuterSubscriber'; | ||
import tryCatch from './util/tryCatch'; | ||
import { errorObject } from './util/errorObject'; | ||
|
||
export default class InnerSubscriber<T, R> extends Subscriber<R> { | ||
index: number = 0; | ||
|
||
constructor(private parent: OuterSubscriber<T, R>, private outerValue: T, private outerIndex: number) { | ||
super(); | ||
} | ||
|
||
_next(value: R) { | ||
const index = this.index++; | ||
this.parent.notifyNext(value, this.outerValue, index, this.outerIndex); | ||
} | ||
|
||
_error(error: any) { | ||
this.parent.notifyError(error, this); | ||
} | ||
|
||
_complete() { | ||
this.parent.notifyComplete(this); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import InnerSubscriber from './InnerSubscriber'; | ||
import Subscriber from './Subscriber'; | ||
|
||
|
||
export default class OuterSubscriber<T, R> extends Subscriber<T> { | ||
notifyComplete(inner?: InnerSubscriber<T, R>) { | ||
this.destination.complete(); | ||
} | ||
|
||
notifyNext(innerValue: R, outerValue: T, innerIndex: number, outerIndex: number) { | ||
this.destination.next(innerValue); | ||
} | ||
|
||
notifyError(error?: any, inner?: InnerSubscriber<T, R>) { | ||
this.destination.error(error); | ||
} | ||
} |
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
Oops, something went wrong.