-
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(operator): implement startWith().
- Loading branch information
1 parent
6447f43
commit 1f36d99
Showing
4 changed files
with
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* globals describe, it, expect */ | ||
var Rx = require('../../dist/cjs/Rx'); | ||
var Observable = Rx.Observable; | ||
|
||
describe('Observable.prototype.startWith()', function () { | ||
it('should start an obsevable with given value', function (done) { | ||
var source = 'source' | ||
var init = 'init'; | ||
var expected = [init, source]; | ||
|
||
var i = 0; | ||
Observable.just(source) | ||
.startWith(init) | ||
.subscribe(function (x) { | ||
expect(x).toBe(expected[i++]); | ||
}, null, function () { | ||
done(); | ||
}); | ||
}); | ||
}); |
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,8 @@ | ||
import Observable from '../Observable'; | ||
import ScalarObservable from '../observables/ScalarObservable'; | ||
import concat from './concat'; | ||
|
||
export default function startWith<T>(x: T): Observable<T> { | ||
const init = new ScalarObservable(x); | ||
return concat.call(init, null, <Observable<T>>this); | ||
} |