Skip to content

Commit

Permalink
feat(Observer): rename complete() callback to end()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros committed Feb 27, 2016
1 parent a814c8a commit d282684
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion perf/runners.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function runRx5(deferred, rxStream) {
function runXStream(deferred, xstream) {
xstream.subscribe({
next: noop,
complete: function() {
end: function() {
deferred.resolve();
},
error: function(e) {
Expand Down
2 changes: 1 addition & 1 deletion src/Observer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface Observer<T> {
next: (x: T) => void;
error: (err: any) => void;
complete: () => void;
end: () => void;
}
6 changes: 3 additions & 3 deletions src/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export class Stream<T> implements Observer<T> {
}
}

complete(): void {
end(): void {
const len = this.observers.length;
if (len === 1) {
this.observers[0].complete();
this.observers[0].end();
} else {
for (let i = 0; i < len; i++) {
this.observers[i].complete();
this.observers[i].end();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/factory/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FromProducer<T> implements Producer<T> {
for (let i = 0; i < L; i++) {
out.next(a[i]);
}
out.complete();
out.end();
}

stop(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/operator/DebugProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DebugProducer<T> implements Producer<T> {
out.next(t);
},
error: (err) => out.error(err),
complete: () => out.complete(),
end: () => out.end(),
};
this.ins.subscribe(this.proxy);
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/FilterProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class Proxy<T> implements Observer<T> {
this.out.error(err);
}

complete() {
this.out.complete();
end() {
this.out.end();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/FoldProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class Proxy<T, R> implements Observer<T> {
this.out.error(err);
}

complete() {
this.out.complete();
end() {
this.out.end();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/LastProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export class Proxy<T> implements Observer<T> {
this.out.error(err);
}

complete() {
end() {
const p = this.p;
const out = this.out;
if (p.has) {
out.next(p.val);
out.complete();
out.end();
} else {
out.error('TODO show proper error');
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/MapProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class Proxy<T, U> implements Observer<T> {
this.out.error(err);
}

complete() {
this.out.complete();
end() {
this.out.end();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operator/SkipProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class SkipProducer<T> implements Producer<T> {
if (this.skipped++ >= this.max) out.next(t);
},
error: (err) => out.error(err),
complete: () => out.complete(),
end: () => out.end(),
};
this.ins.subscribe(this.proxy);
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/TakeProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export class TakeProducer<T> implements Producer<T> {
if (this.taken++ < this.max) {
out.next(t);
} else {
out.complete();
out.end();
this.stop();
}
},
error: (err) => out.error(err),
complete: () => out.complete(),
end: () => out.end(),
};
this.ins.subscribe(this.proxy);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/emptyObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import {Observer} from '../Observer';
export var emptyObserver: Observer<any> = {
next: null,
error: null,
complete: null,
end: null,
};
2 changes: 1 addition & 1 deletion tests/factory/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Stream.prototype.from', () => {
assert.equal(x, expected.shift());
},
error: done.fail,
complete: () => {
end: () => {
assert.equal(expected.length, 0);
done();
},
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Stream.prototype.debug', () => {
}
},
error: done.fail,
complete: done.fail,
end: done.fail,
};
stream.subscribe(observer);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Stream.prototype.filter', () => {
}
},
error: done.fail,
complete: done.fail,
end: done.fail,
};
stream.subscribe(observer);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/fold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Stream.prototype.fold', () => {
assert.equal(x, expected.shift());
},
error: done.fail,
complete: () => {
end: () => {
assert.equal(expected.length, 0);
stream.unsubscribe(observer);
done();
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Stream.prototype.last', () => {
assert.equal(x, expected.shift());
},
error: done.fail,
complete: () => {
end: () => {
assert.equal(expected.length, 0);
stream.unsubscribe(observer);
done();
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Stream.prototype.map', () => {
}
},
error: done.fail,
complete: done.fail,
end: done.fail,
};
stream.subscribe(observer);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Stream.prototype.skip', () => {
}
},
error: done.fail,
complete: done.fail,
end: done.fail,
};
stream.subscribe(observer);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/operator/take.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Stream.prototype.take', () => {
assert.equal(x, expected.shift());
},
error: done.fail,
complete: () => {
end: () => {
assert.equal(expected.length, 0);
stream.unsubscribe(observer);
done();
Expand Down
2 changes: 1 addition & 1 deletion tests/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Stream', () => {
}
},
error: done.fail,
complete: done.fail,
end: done.fail,
};
stream.subscribe(observer);
});
Expand Down

0 comments on commit d282684

Please sign in to comment.