diff --git a/packages/realm/src/ProgressRealmPromise.ts b/packages/realm/src/ProgressRealmPromise.ts index e3e5db1120..9a12e6e343 100644 --- a/packages/realm/src/ProgressRealmPromise.ts +++ b/packages/realm/src/ProgressRealmPromise.ts @@ -41,7 +41,7 @@ type OpenBehavior = { function determineBehavior(config: Configuration, realmExists: boolean): OpenBehavior { const { sync, openSyncedRealmLocally } = config; if (!sync || openSyncedRealmLocally) { - return { openBehavior: Realm.App.Sync.defaultLocalOpenRealmConfiguration.type }; + return { openBehavior: OpenRealmBehaviorType.OpenImmediately }; } else { const configProperty = realmExists ? "existingRealmFileBehavior" : "newRealmFileBehavior"; const configBehavior = sync[configProperty]; @@ -52,8 +52,11 @@ function determineBehavior(config: Configuration, realmExists: boolean): OpenBeh } return { openBehavior: type, timeOut, timeOutBehavior }; } else { - const { type, timeOut, timeOutBehavior } = Realm.App.Sync.defaultSyncOpenRealmConfiguration; - return { openBehavior: type, timeOut, timeOutBehavior }; + return { + openBehavior: OpenRealmBehaviorType.DownloadBeforeOpen, + timeOut: 30 * 1000, + timeOutBehavior: OpenRealmTimeOutBehavior.ThrowException, + }; } } } diff --git a/packages/realm/src/app-services/Sync.ts b/packages/realm/src/app-services/Sync.ts index 24a5b6fb57..c1dcfcd626 100644 --- a/packages/realm/src/app-services/Sync.ts +++ b/packages/realm/src/app-services/Sync.ts @@ -172,33 +172,22 @@ export class Sync { } /** - * The default OpenRealmBehaviorConfiguration used for local realms. - * This is used if the behavior is not specified by the developer when opening the realm. - * @internal + * The default behavior settings if you want to open a synchronized Realm immediately and start working on it. + * If this is the first time you open the Realm, it will be empty while the server data is being downloaded in the background. + * @deprecated since v12 */ - static defaultLocalOpenRealmConfiguration: Readonly = { + + static openLocalRealmBehavior: Readonly = { type: OpenRealmBehaviorType.OpenImmediately, }; /** - * The default OpenRealmBehaviorConfiguration used for synced realms. - * This is used if the behavior is not specified by the developer when opening the realm. - * @internal + * The default behavior settings if you want to wait for downloading a synchronized Realm to complete before opening it. + * @deprecated since v12 */ - static defaultSyncOpenRealmConfiguration: Readonly = { + static downloadBeforeOpenBehavior: Readonly = { type: OpenRealmBehaviorType.DownloadBeforeOpen, timeOut: 30 * 1000, timeOutBehavior: OpenRealmTimeOutBehavior.ThrowException, }; - - /** - * The default behavior settings if you want to open a synchronized Realm immediately and start working on it. - * If this is the first time you open the Realm, it will be empty while the server data is being downloaded in the background. - */ - static openLocalRealmBehavior = Sync.defaultLocalOpenRealmConfiguration; - - /** - * The default behavior settings if you want to wait for downloading a synchronized Realm to complete before opening it. - */ - static downloadBeforeOpenBehavior = Sync.defaultSyncOpenRealmConfiguration; } diff --git a/packages/realm/src/app-services/SyncConfiguration.ts b/packages/realm/src/app-services/SyncConfiguration.ts index 36a507f153..0f125ff4e6 100644 --- a/packages/realm/src/app-services/SyncConfiguration.ts +++ b/packages/realm/src/app-services/SyncConfiguration.ts @@ -208,11 +208,23 @@ export type BaseSyncConfiguration = { user: AnyUser; /** * Whether to create a new file and sync in background or wait for the file to be synced. + * @default + * { + * type: OpenRealmBehaviorType.DownloadBeforeOpen, + * timeOut: 30 * 1000, + * timeOutBehavior: OpenRealmTimeOutBehavior.ThrowException, + * } */ newRealmFileBehavior?: OpenRealmBehaviorConfiguration; /** * Whether to open existing file and sync in background or wait for the sync of the file to complete and then open. * If not set, the Realm will be downloaded before opened. + * @default + * { + * type: OpenRealmBehaviorType.DownloadBeforeOpen, + * timeOut: 30 * 1000, + * timeOutBehavior: OpenRealmTimeOutBehavior.ThrowException, + * } */ existingRealmFileBehavior?: OpenRealmBehaviorConfiguration; /**