Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
refactor: make it obvious what the subscribe function does.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Jul 18, 2021
1 parent fa545af commit a13b313
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rxToStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ReadableObservableStream<T> extends stream.Readable {
) {
super(streamOptions(options));
if (options.lazy === false) {
this.subscribe();
this.subscribeIfNecessary();
}
}

Expand All @@ -70,7 +70,7 @@ class ReadableObservableStream<T> extends stream.Readable {
_read() {
const { _buffer } = this;

this.subscribe();
this.subscribeIfNecessary();

if (_buffer.length > 0) {
while (_buffer.length > 0) {
Expand All @@ -90,7 +90,7 @@ class ReadableObservableStream<T> extends stream.Readable {
}
}

private subscribe() {
private subscribeIfNecessary() {
if (this._subscription) return;

const { _buffer } = this;
Expand Down

0 comments on commit a13b313

Please sign in to comment.