-
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.
feat(publishLast): add higher-order lettable version of publishLast
- Loading branch information
Showing
3 changed files
with
13 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { Observable } from '../Observable'; | ||
import { AsyncSubject } from '../AsyncSubject'; | ||
import { multicast } from './multicast'; | ||
import { ConnectableObservable } from '../observable/ConnectableObservable'; | ||
|
||
import { publishLast as higherOrder } from '../operators'; | ||
/** | ||
* @return {ConnectableObservable<T>} | ||
* @method publishLast | ||
* @owner Observable | ||
*/ | ||
export function publishLast<T>(this: Observable<T>): ConnectableObservable<T> { | ||
return multicast.call(this, new AsyncSubject<T>()); | ||
//TODO(benlesh): correct type-flow through here. | ||
return higherOrder()(this) as ConnectableObservable<T>; | ||
} |
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,9 @@ | ||
import { Observable } from '../Observable'; | ||
import { AsyncSubject } from '../AsyncSubject'; | ||
import { multicast } from './multicast'; | ||
import { OperatorFunction } from '../interfaces'; | ||
|
||
//TODO(benlesh): specify that the second type is actually a ConnectableObservable | ||
export function publishLast<T>(): OperatorFunction<T, T> { | ||
return (source: Observable<T>) => multicast(new AsyncSubject<T>())(source); | ||
} |