-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(startWith): implement startWith operator
Add implementation for startWith Fix this.proxy compiler error in RememberOperator
- Loading branch information
Showing
3 changed files
with
31 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import {Operator} from '../Operator'; | ||
import {Stream, MemoryStream} from '../Stream'; | ||
import {Operator} from '../Operator'; | ||
import {Observer} from '../Observer'; | ||
import {emptyObserver} from '../utils/emptyObserver'; | ||
|
||
export class RememberOperator<T> implements Operator<T, T> { | ||
public value: any; | ||
public out: Observer<T> = emptyObserver; | ||
|
||
constructor(public ins: Stream<T>) { | ||
} | ||
|
||
start(out: MemoryStream<T>): void { | ||
this.out = out; | ||
this.ins.subscribe(out); | ||
} | ||
|
||
stop(): void { | ||
this.ins.unsubscribe(this.proxy); | ||
this.ins.unsubscribe(this.out); | ||
} | ||
} |
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,20 @@ | ||
import {Stream} from '../Stream'; | ||
import {Observer} from '../Observer'; | ||
import {Operator} from '../Operator'; | ||
import {emptyObserver} from '../utils/emptyObserver'; | ||
|
||
export class StartWithOperator<T> implements Operator<T, T> { | ||
public out: Observer<T> = emptyObserver; | ||
constructor(public ins: Stream<T>, public value: T) { | ||
} | ||
|
||
start(out: Observer<T>): void { | ||
this.out = out; | ||
this.out.next(this.value); | ||
this.ins.subscribe(out); | ||
} | ||
|
||
stop(): void { | ||
this.ins.unsubscribe(this.out); | ||
} | ||
} |