Skip to content

Commit a0605e6

Browse files
schmidt-sebastianFeiyang1
authored andcommitted
Rename multi-tab setting to synchronizeTabs (#1728)
* Rename multi-tab setting to synchronizeTabs * [AUTOMATED]: Prettier Code Styling * Update error message
1 parent 9d16808 commit a0605e6

File tree

6 files changed

+61
-22
lines changed

6 files changed

+61
-22
lines changed

packages/firebase/index.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5903,11 +5903,20 @@ declare namespace firebase.firestore {
59035903
* shared execution of queries and latency-compensated local document updates
59045904
* across all connected instances.
59055905
*
5906-
* To enable this mode, `experimentalTabSynchronization:true` needs to be set
5907-
* globally in all active tabs. If omitted or set to 'false',
5908-
* `enablePersistence()` will fail in all but the first tab.
5906+
* To enable this mode, `synchronizeTabs:true` needs to be set globally in all
5907+
* active tabs. If omitted or set to 'false', `enablePersistence()` will fail
5908+
* in all but the first tab.
5909+
*/
5910+
synchronizeTabs?: boolean;
5911+
5912+
/**
5913+
* Whether to synchronize the in-memory state of multiple tabs. Setting this
5914+
* to 'true' in all open tabs enables shared access to local persistence,
5915+
* shared execution of queries and latency-compensated local document updates
5916+
* across all connected instances.
59095917
*
5910-
* NOTE: This mode is not yet recommended for production use.
5918+
* @deprecated This setting is deprecated. To enabled synchronization between
5919+
* multiple tabs, please use `synchronizeTabs: true` instead.
59115920
*/
59125921
experimentalTabSynchronization?: boolean;
59135922
}

packages/firestore-types/index.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ export interface PersistenceSettings {
106106
* shared execution of queries and latency-compensated local document updates
107107
* across all connected instances.
108108
*
109-
* To enable this mode, `experimentalTabSynchronization:true` needs to be set
110-
* globally in all active tabs. If omitted or set to 'false',
111-
* `enablePersistence()` will fail in all but the first tab.
109+
* To enable this mode, `synchronizeTabs:true` needs to be set globally in all
110+
* active tabs. If omitted or set to 'false', `enablePersistence()` will fail
111+
* in all but the first tab.
112+
*/
113+
synchronizeTabs?: boolean;
114+
115+
/**
116+
* Whether to synchronize the in-memory state of multiple tabs. Setting this
117+
* to 'true' in all open tabs enables shared access to local persistence,
118+
* shared execution of queries and latency-compensated local document updates
119+
* across all connected instances.
112120
*
113-
* NOTE: This mode is not yet recommended for production use.
121+
* @deprecated This setting is deprecated. To enabled synchronization between
122+
* multiple tabs, please use `synchronizeTabs: true` instead.
114123
*/
115124
experimentalTabSynchronization?: boolean;
116125
}

packages/firestore/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# Unreleased (I/O)
1+
2+
# Unreleased
3+
- [changed] Deprecated the `experimentalTabSynchronization` setting in favor of
4+
`synchronizeTabs`. If you use multi-tab synchronization, it is recommended
5+
that you update your call to `enablePersistence()`. Firestore logs an error
6+
if you continue to use `experimentalTabSynchronization`.
27
- [feature] You can now query across all collections in your database with a
3-
given collection ID using the `FirebaseFirestore.collectionGroup()` method.
8+
given collection ID using the `FirebaseFirestore.collectionGroup()` method.
49

510
# 1.1.4
611
- [feature] Added an `experimentalForceLongPolling` setting that that can be

packages/firestore/src/api/database.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,30 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
398398
'any other methods on a Firestore object.'
399399
);
400400
}
401+
402+
let synchronizeTabs = false;
403+
404+
if (settings) {
405+
if (settings.experimentalTabSynchronization !== undefined) {
406+
log.error(
407+
"The 'experimentalTabSynchronization' setting has been renamed to " +
408+
"'synchronizeTabs'. In a future release, the setting will be removed " +
409+
'and it is recommended that you update your ' +
410+
"firestore.enablePersistence() call to use 'synchronizeTabs'."
411+
);
412+
}
413+
synchronizeTabs = objUtils.defaulted(
414+
settings.synchronizeTabs !== undefined
415+
? settings.synchronizeTabs
416+
: settings.experimentalTabSynchronization,
417+
DEFAULT_SYNCHRONIZE_TABS
418+
);
419+
}
420+
401421
return this.configureClient(
402422
new IndexedDbPersistenceSettings(
403423
this._config.settings.cacheSizeBytes,
404-
settings !== undefined &&
405-
objUtils.defaulted(
406-
settings.experimentalTabSynchronization,
407-
DEFAULT_SYNCHRONIZE_TABS
408-
)
424+
synchronizeTabs
409425
)
410426
);
411427
}

packages/firestore/src/core/firestore_client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const DOM_EXCEPTION_QUOTA_EXCEEDED = 22;
7474
export class IndexedDbPersistenceSettings {
7575
constructor(
7676
readonly cacheSizeBytes: number,
77-
readonly experimentalTabSynchronization: boolean
77+
readonly synchronizeTabs: boolean
7878
) {}
7979

8080
lruParams(): LruParams {
@@ -334,7 +334,7 @@ export class FirestoreClient {
334334

335335
return Promise.resolve().then(async () => {
336336
if (
337-
settings.experimentalTabSynchronization &&
337+
settings.synchronizeTabs &&
338338
!WebStorageSharedClientState.isAvailable(this.platform)
339339
) {
340340
throw new FirestoreError(
@@ -345,7 +345,7 @@ export class FirestoreClient {
345345

346346
let persistence: IndexedDbPersistence;
347347
const lruParams = settings.lruParams();
348-
if (settings.experimentalTabSynchronization) {
348+
if (settings.synchronizeTabs) {
349349
this.sharedClientState = new WebStorageSharedClientState(
350350
this.asyncQueue,
351351
this.platform,

packages/firestore/src/local/indexeddb_persistence.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const PRIMARY_LEASE_LOST_ERROR_MSG =
103103
const PRIMARY_LEASE_EXCLUSIVE_ERROR_MSG =
104104
'Another tab has exclusive access to the persistence layer. ' +
105105
'To allow shared access, make sure to invoke ' +
106-
'`enablePersistence()` with `experimentalTabSynchronization:true` in all tabs.';
106+
'`enablePersistence()` with `synchronizeTabs:true` in all tabs.';
107107
const UNSUPPORTED_PLATFORM_ERROR_MSG =
108108
'This platform is either missing' +
109109
' IndexedDB or is known to have an incomplete implementation. Offline' +
@@ -130,7 +130,7 @@ export class IndexedDbTransaction extends PersistenceTransaction {
130130
* layer. This allows multiple browser tabs to read and write to IndexedDb and
131131
* to synchronize state even without network connectivity. Shared access is
132132
* currently optional and not enabled unless all clients invoke
133-
* `enablePersistence()` with `{experimentalTabSynchronization:true}`.
133+
* `enablePersistence()` with `{synchronizeTabs:true}`.
134134
*
135135
* In multi-tab mode, if multiple clients are active at the same time, the SDK
136136
* will designate one client as the “primary client”. An effort is made to pick
@@ -165,8 +165,8 @@ export class IndexedDbTransaction extends PersistenceTransaction {
165165
* LocalStorage which acts as an indicator that another tab should go ahead and
166166
* take the primary lease immediately regardless of the current lease timestamp.
167167
*
168-
* TODO(b/114226234): Remove `experimentalTabSynchronization` section when
169-
* multi-tab is no longer optional.
168+
* TODO(b/114226234): Remove `synchronizeTabs` section when multi-tab is no
169+
* longer optional.
170170
*/
171171
export type MultiClientParams = {
172172
sequenceNumberSyncer: SequenceNumberSyncer;

0 commit comments

Comments
 (0)