@@ -64,21 +64,21 @@ export interface WriteRequest extends api.WriteRequest {
64
64
enum PersistentStreamState {
65
65
/**
66
66
* 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.
69
69
*/
70
70
Initial ,
71
71
72
72
/**
73
73
* 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.
76
76
*/
77
77
Starting ,
78
78
79
79
/**
80
80
* 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.
82
82
*/
83
83
Open ,
84
84
@@ -91,7 +91,7 @@ enum PersistentStreamState {
91
91
/**
92
92
* An in-between state after an error where the stream is waiting before
93
93
* 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
95
95
* false.
96
96
*/
97
97
Backoff
@@ -144,12 +144,12 @@ const IDLE_TIMEOUT_MS = 60 * 1000;
144
144
*
145
145
* ## Starting and Stopping
146
146
*
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
149
149
* of the listener once the stream is ready to accept requests.
150
150
*
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.
153
153
*
154
154
* A PersistentStream can be started and stopped repeatedly.
155
155
*
@@ -173,7 +173,7 @@ export abstract class PersistentStream<
173
173
*/
174
174
private closeCount = 0 ;
175
175
176
- private inactivityTimerPromise : CancelablePromise < void > | null = null ;
176
+ private idleTimer : CancelablePromise < void > | null = null ;
177
177
private stream : Stream < SendType , ReceiveType > | null = null ;
178
178
179
179
protected backoff : ExponentialBackoff ;
@@ -196,10 +196,10 @@ export abstract class PersistentStream<
196
196
}
197
197
198
198
/**
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
200
200
* indicates the stream is open or in the process of opening (which
201
201
* 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
203
203
* outbound requests.
204
204
*/
205
205
isStarted ( ) : boolean {
@@ -211,19 +211,19 @@ export abstract class PersistentStream<
211
211
}
212
212
213
213
/**
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
215
215
* called) and the stream is ready for outbound requests.
216
216
*/
217
217
isOpen ( ) : boolean {
218
218
return this . state === PersistentStreamState . Open ;
219
219
}
220
220
221
221
/**
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.
225
225
*
226
- * When start returns, isStarted will return true.
226
+ * When start returns, isStarted() will return true.
227
227
*/
228
228
start ( ) : void {
229
229
if ( this . state === PersistentStreamState . Error ) {
@@ -237,9 +237,9 @@ export abstract class PersistentStream<
237
237
238
238
/**
239
239
* Stops the RPC. This call is idempotent and allowed regardless of the
240
- * current isStarted state.
240
+ * current isStarted() state.
241
241
*
242
- * When stop returns, isStarted and isOpen will both return false.
242
+ * When stop returns, isStarted() and isOpen() will both return false.
243
243
*/
244
244
stop ( ) : void {
245
245
if ( this . isStarted ( ) ) {
@@ -252,7 +252,7 @@ export abstract class PersistentStream<
252
252
* start it. If the error warrants an immediate restart of the stream, the
253
253
* sender can use this to indicate that the receiver should not back off.
254
254
*
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
256
256
* inhibit backoff if required.
257
257
*/
258
258
inhibitBackoff ( ) : void {
@@ -275,8 +275,8 @@ export abstract class PersistentStream<
275
275
markIdle ( ) : void {
276
276
// Starts the idle time if we are in state 'Open' and are not yet already
277
277
// 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 (
280
280
this . idleTimerId ,
281
281
IDLE_TIMEOUT_MS ,
282
282
( ) => this . handleIdleCloseTimer ( )
@@ -301,9 +301,9 @@ export abstract class PersistentStream<
301
301
302
302
/** Marks the stream as active again. */
303
303
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 ;
307
307
}
308
308
}
309
309
@@ -315,7 +315,7 @@ export abstract class PersistentStream<
315
315
* * sets internal stream state to 'finalState';
316
316
* * adjusts the backoff timer based on the error
317
317
*
318
- * A new stream can be opened by calling ` start` .
318
+ * A new stream can be opened by calling start() .
319
319
*
320
320
* @param finalState the intended state of the stream after closing.
321
321
* @param error the error the connection was closed with.
@@ -532,9 +532,9 @@ export interface WatchStreamListener extends PersistentStreamListener {
532
532
/**
533
533
* A PersistentStream that implements the Listen RPC.
534
534
*
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.
538
538
*/
539
539
export class PersistentListenStream extends PersistentStream <
540
540
api . ListenRequest ,
0 commit comments