Skip to content

Commit

Permalink
style(ReplaySubject): rename windowSize argument to be windowTime
Browse files Browse the repository at this point in the history
This is because the size is a time unit in milliseconds. Just a disambiguation
  • Loading branch information
benlesh committed Feb 10, 2016
1 parent 16894bb commit b35564e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/subject/ReplaySubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export class ReplaySubject<T> extends Subject<T> {
private events: ReplayEvent<T>[] = [];
private scheduler: Scheduler;
private bufferSize: number;
private windowSize: number;
private _windowTime: number;

constructor(bufferSize: number = Number.POSITIVE_INFINITY,
windowSize: number = Number.POSITIVE_INFINITY,
windowTime: number = Number.POSITIVE_INFINITY,
scheduler?: Scheduler) {
super();
this.scheduler = scheduler;
this.bufferSize = bufferSize < 1 ? 1 : bufferSize;
this.windowSize = windowSize < 1 ? 1 : windowSize;
this._windowTime = windowTime < 1 ? 1 : windowTime;
}

protected _next(value: T): void {
Expand Down Expand Up @@ -49,7 +49,7 @@ export class ReplaySubject<T> extends Subject<T> {

private _trimBufferThenGetEvents(now: number): ReplayEvent<T>[] {
const bufferSize = this.bufferSize;
const windowSize = this.windowSize;
const _windowTime = this._windowTime;
const events = this.events;

let eventsCount = events.length;
Expand All @@ -59,7 +59,7 @@ export class ReplaySubject<T> extends Subject<T> {
// Start at the front of the list. Break early once
// we encounter an event that falls within the window.
while (spliceCount < eventsCount) {
if ((now - events[spliceCount].time) < windowSize) {
if ((now - events[spliceCount].time) < _windowTime) {
break;
}
spliceCount += 1;
Expand Down

0 comments on commit b35564e

Please sign in to comment.