Skip to content

Commit 43b64b5

Browse files
Merge branch 'master' into multitab-gregandkosta-dirty
2 parents 3bcf756 + e8460bc commit 43b64b5

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

packages/firestore/src/remote/persistent_stream.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ export interface WriteRequest extends api.WriteRequest {
6464
enum PersistentStreamState {
6565
/**
6666
* The streaming RPC is not yet running and there's no error condition.
67-
* Calling `start` will start the stream immediately without backoff.
68-
* While in this state isStarted will return false.
67+
* Calling start() will start the stream immediately without backoff.
68+
* While in this state isStarted() will return false.
6969
*/
7070
Initial,
7171

7272
/**
7373
* The stream is starting, either waiting for an auth token or for the stream
74-
* to successfully open. While in this state, isStarted will return true but
75-
* isOpen will return false.
74+
* to successfully open. While in this state, isStarted() will return true but
75+
* isOpen() will return false.
7676
*/
7777
Starting,
7878

7979
/**
8080
* The streaming RPC is up and running. Requests and responses can flow
81-
* freely. Both isStarted and isOpen will return true.
81+
* freely. Both isStarted() and isOpen() will return true.
8282
*/
8383
Open,
8484

@@ -91,7 +91,7 @@ enum PersistentStreamState {
9191
/**
9292
* An in-between state after an error where the stream is waiting before
9393
* re-starting. After waiting is complete, the stream will try to open.
94-
* While in this state isStarted() will return true but isOpen will return
94+
* While in this state isStarted() will return true but isOpen() will return
9595
* false.
9696
*/
9797
Backoff
@@ -144,12 +144,12 @@ const IDLE_TIMEOUT_MS = 60 * 1000;
144144
*
145145
* ## Starting and Stopping
146146
*
147-
* Streaming RPCs are stateful and need to be `start`ed before messages can
148-
* be sent and received. The PersistentStream will call the onOpen function
147+
* Streaming RPCs are stateful and need to be start()ed before messages can
148+
* be sent and received. The PersistentStream will call the onOpen() function
149149
* of the listener once the stream is ready to accept requests.
150150
*
151-
* Should a `start` fail, PersistentStream will call the registered
152-
* onClose with a FirestoreError indicating what went wrong.
151+
* Should a start() fail, PersistentStream will call the registered onClose()
152+
* listener with a FirestoreError indicating what went wrong.
153153
*
154154
* A PersistentStream can be started and stopped repeatedly.
155155
*
@@ -173,7 +173,7 @@ export abstract class PersistentStream<
173173
*/
174174
private closeCount = 0;
175175

176-
private inactivityTimerPromise: CancelablePromise<void> | null = null;
176+
private idleTimer: CancelablePromise<void> | null = null;
177177
private stream: Stream<SendType, ReceiveType> | null = null;
178178

179179
protected backoff: ExponentialBackoff;
@@ -196,10 +196,10 @@ export abstract class PersistentStream<
196196
}
197197

198198
/**
199-
* Returns true if `start` has been called and no error has occurred. True
199+
* Returns true if start() has been called and no error has occurred. True
200200
* indicates the stream is open or in the process of opening (which
201201
* encompasses respecting backoff, getting auth tokens, and starting the
202-
* actual RPC). Use `isOpen` to determine if the stream is open and ready for
202+
* actual RPC). Use isOpen() to determine if the stream is open and ready for
203203
* outbound requests.
204204
*/
205205
isStarted(): boolean {
@@ -211,19 +211,19 @@ export abstract class PersistentStream<
211211
}
212212

213213
/**
214-
* Returns true if the underlying RPC is open (the onOpen callback has been
214+
* Returns true if the underlying RPC is open (the onOpen() listener has been
215215
* called) and the stream is ready for outbound requests.
216216
*/
217217
isOpen(): boolean {
218218
return this.state === PersistentStreamState.Open;
219219
}
220220

221221
/**
222-
* Starts the RPC. Only allowed if isStarted returns false. The stream is
223-
* not immediately ready for use: onOpen will be invoked when the RPC is ready
224-
* for outbound requests, at which point isOpen will return true.
222+
* Starts the RPC. Only allowed if isStarted() returns false. The stream is
223+
* not immediately ready for use: onOpen() will be invoked when the RPC is
224+
* ready for outbound requests, at which point isOpen() will return true.
225225
*
226-
* When start returns, isStarted will return true.
226+
* When start returns, isStarted() will return true.
227227
*/
228228
start(): void {
229229
if (this.state === PersistentStreamState.Error) {
@@ -237,9 +237,9 @@ export abstract class PersistentStream<
237237

238238
/**
239239
* Stops the RPC. This call is idempotent and allowed regardless of the
240-
* current isStarted state.
240+
* current isStarted() state.
241241
*
242-
* When stop returns, isStarted and isOpen will both return false.
242+
* When stop returns, isStarted() and isOpen() will both return false.
243243
*/
244244
stop(): void {
245245
if (this.isStarted()) {
@@ -252,7 +252,7 @@ export abstract class PersistentStream<
252252
* start it. If the error warrants an immediate restart of the stream, the
253253
* sender can use this to indicate that the receiver should not back off.
254254
*
255-
* Each error will call the onClose function. That function can decide to
255+
* Each error will call the onClose() listener. That function can decide to
256256
* inhibit backoff if required.
257257
*/
258258
inhibitBackoff(): void {
@@ -275,8 +275,8 @@ export abstract class PersistentStream<
275275
markIdle(): void {
276276
// Starts the idle time if we are in state 'Open' and are not yet already
277277
// running a timer (in which case the previous idle timeout still applies).
278-
if (this.isOpen() && this.inactivityTimerPromise === null) {
279-
this.inactivityTimerPromise = this.queue.enqueueAfterDelay(
278+
if (this.isOpen() && this.idleTimer === null) {
279+
this.idleTimer = this.queue.enqueueAfterDelay(
280280
this.idleTimerId,
281281
IDLE_TIMEOUT_MS,
282282
() => this.handleIdleCloseTimer()
@@ -301,9 +301,9 @@ export abstract class PersistentStream<
301301

302302
/** Marks the stream as active again. */
303303
private cancelIdleCheck(): void {
304-
if (this.inactivityTimerPromise) {
305-
this.inactivityTimerPromise.cancel();
306-
this.inactivityTimerPromise = null;
304+
if (this.idleTimer) {
305+
this.idleTimer.cancel();
306+
this.idleTimer = null;
307307
}
308308
}
309309

@@ -315,7 +315,7 @@ export abstract class PersistentStream<
315315
* * sets internal stream state to 'finalState';
316316
* * adjusts the backoff timer based on the error
317317
*
318-
* A new stream can be opened by calling `start`.
318+
* A new stream can be opened by calling start().
319319
*
320320
* @param finalState the intended state of the stream after closing.
321321
* @param error the error the connection was closed with.
@@ -532,9 +532,9 @@ export interface WatchStreamListener extends PersistentStreamListener {
532532
/**
533533
* A PersistentStream that implements the Listen RPC.
534534
*
535-
* Once the Listen stream has called the openHandler, any number of listen and
536-
* unlisten calls calls can be sent to control what changes will be sent from
537-
* the server for ListenResponses.
535+
* Once the Listen stream has called the onOpen() listener, any number of
536+
* listen() and unlisten() calls can be made to control what changes will be
537+
* sent from the server for ListenResponses.
538538
*/
539539
export class PersistentListenStream extends PersistentStream<
540540
api.ListenRequest,

0 commit comments

Comments
 (0)