Skip to content

Commit

Permalink
fix(compose): improve compose type signature
Browse files Browse the repository at this point in the history
Use generic instead of returning Stream<any>.
  • Loading branch information
staltz committed Jun 3, 2016
1 parent 512969d commit 38b1064
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ export class Stream<T> implements InternalListener<T> {
* returns a stream as well.
* @return {Stream}
*/
compose(operator: (stream: Stream<T>) => Stream<any>): Stream<any> {
compose<U>(operator: (stream: Stream<T>) => Stream<U>): Stream<U> {
return operator(this);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/extra/flattenSequentially.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('flattenSequentially (extra)', () => {
.compose(flattenSequentially);
const expected = ['10', '11', '12', '20', '21', '22', '30', '31', '32'];
const listener = {
next: (x: number) => {
next: (x: string) => {
assert.equal(x, expected.shift());
},
error: (err: any) => done(err),
Expand All @@ -52,7 +52,7 @@ describe('flattenSequentially (extra)', () => {
// -----------30----------31
const expected = ['10', '11', '20', '21', '30', '31'];
const listener = {
next: (x: number) => {
next: (x: string) => {
assert.equal(x, expected.shift());
},
error: (err: any) => done(err),
Expand All @@ -76,7 +76,7 @@ describe('flattenSequentially (extra)', () => {
// ------------20-----------21----------22
const expected = ['00', '01', '02', '10', '11', '12', '20', '21', '22'];
stream.addListener({
next: (x: number) => {
next: (x: string) => {
assert.equal(x, expected.shift());
},
error: (err: any) => done(err),
Expand All @@ -101,7 +101,7 @@ describe('flattenSequentially (extra)', () => {

const expected = ['00', '01', '02', '10', '11', '12', '20', '21', '22'];
const listener = {
next: (x: number) => {
next: (x: string) => {
assert.equal(x, expected.shift());
},
error: (err: any) => done(err),
Expand Down
2 changes: 1 addition & 1 deletion tests/mimicStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('MimicStream', () => {
it('should be able to model a circular dependency in the stream graph', (done) => {
const fakeSecond = xs.createMimic<number>();
const first = fakeSecond.map(x => x * 10).take(3);
const second = first.map(x => x + 1).startWith(1).compose(delay(1));
const second = first.map(x => x + 1).startWith(1).compose(delay<number>(1));
fakeSecond.imitate(second);
const expected = [1, 11, 111, 1111];

Expand Down

0 comments on commit 38b1064

Please sign in to comment.