-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(bufferTime): do not create buffer when unsubscribed #1949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ class BufferTimeSubscriber<T> extends Subscriber<T> { | |
private scheduler: Scheduler) { | ||
super(destination); | ||
const context = this.openContext(); | ||
this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0; | ||
this.timespanOnly = bufferCreationInterval === null || bufferCreationInterval < 0; | ||
if (this.timespanOnly) { | ||
const timeSpanOnlyState = { subscriber: this, context, bufferTimeSpan }; | ||
this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState)); | ||
|
@@ -168,13 +168,13 @@ class BufferTimeSubscriber<T> extends Subscriber<T> { | |
this.contexts = null; | ||
} | ||
|
||
protected onBufferFull(context: Context<T>) { | ||
protected onBufferFull(context: Context<T>): void { | ||
this.closeContext(context); | ||
const closeAction = context.closeAction; | ||
closeAction.unsubscribe(); | ||
this.remove(closeAction); | ||
|
||
if (this.timespanOnly) { | ||
if (this.timespanOnly && this.contexts !== null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is actual changes, do not attempt to open buffer if it's already unsubscribed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get a regression test around this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. This occurs with async context, not able to think trivial way to create test cases at the moment writing PR. Let me think a bit more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this bit, but wasn't able to come up with clean way to create test coverage via test scheduler (or synchronous way) to mimic unsubscription occurs before scheduled action triggered. |
||
context = this.openContext(); | ||
const bufferTimeSpan = this.bufferTimeSpan; | ||
const timeSpanOnlyState = { subscriber: this, context, bufferTimeSpan }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help me understand plz, why is there a notable difference between
undefined
andnull
here? i.e. why the fact that== null
would matchundefined
too is a problem?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, it's my bad. apologize. This isn't legit complete fix and code should be updated more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew! I was racking my brain!! 😅😅