-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swift: Add docs for SyncSession.reconnect() (#3062)
## Pull Request Info A few questions for a tech reviewer based on the similar docs in Kotlin: - In Kotlin, we say "The SDK also automatically calls this method when a device toggles off airplane mode" - is this accurate in the Swift SDK, also? I didn't see anything special for this in the SDK PR so wondering if this is something in Core? - In Kotlin, we say "the SDK forces all sync sessions to attempt to reconnect immediately" - is this also true in Swift, or is it forcing only the `SyncSession` you call it on to reconnect? Does this change with session multiplexing enabled/disabled? - Kotlin has a callout about not being able to force a reconnection within the socket read timeout duration - is this also true in Swift? - It seems the [RLMSyncSession got docs for the new method](https://www.mongodb.com/docs/realm-sdks/objc/latest/Classes/RLMSyncSession.html), but [Swift's SyncSession](https://www.mongodb.com/docs/realm-sdks/swift/latest/Extensions/SyncSession.html) didn't. Could we add this, or am I looking in the wrong place? ### Jira - https://jira.mongodb.org/browse/DOCSP-33926 ### Staged Changes - [Manage Sync Sessions](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-33926/sdk/swift/sync/sync-session/) The rest of the examples in the test file were still using Partition-Based Sync, so I also updated those examples to FS. Those examples are at: - [Configure & Open a Synced Realm](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-33926/sdk/swift/sync/configure-and-open-a-synced-realm/#download-changes-before-open) ### Reminder Checklist If your PR modifies the docs, you might need to also update some corresponding pages. Check if completed or N/A. - [x] Create Jira ticket for corresponding docs-app-services update(s), if any - [x] Checked/updated Admin API - [x] Checked/updated CLI reference ### Review Guidelines [REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)
- Loading branch information
Showing
6 changed files
with
111 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
.../examples/generated/code/start/Sync.snippet.specify-download-behavior.swift.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
.. code-block:: swift | ||
:emphasize-lines: 6 | ||
:emphasize-lines: 7 | ||
func testSpecifyDownloadBehavior() async throws { | ||
let app = App(id: YOUR_REALM_APP_ID) | ||
func getRealmAfterDownloadingUpdates() async throws -> Realm { | ||
let app = App(id: APPID) | ||
let user = try await app.login(credentials: Credentials.anonymous) | ||
let partitionValue = "some partition value" | ||
var configuration = user.configuration(partitionValue: partitionValue) | ||
var configuration = user.flexibleSyncConfiguration() | ||
configuration.objectTypes = [FlexibleSync_Task.self, FlexibleSync_Team.self] | ||
let realm = try await Realm(configuration: configuration, downloadBeforeOpen: .always) | ||
print("Successfully opened realm after downloading: \(realm)") | ||
return realm | ||
} | ||
let realm = try await getRealmAfterDownloadingUpdates() | ||
print("The open realm is: \(realm)") | ||
// Add subscription and work with the realm |
4 changes: 4 additions & 0 deletions
4
source/examples/generated/code/start/Sync.snippet.sync-session-reconnect.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let syncSession = realm.syncSession! | ||
|
||
// Work with the realm. When you need to force the sync session to reconnect... | ||
syncSession.reconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters