-
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.
(DOCSP-34055): Swift: Add docs for wait for upload/download (#3076)
## Pull Request Info While the eng PR this documents has been merged to master, it is not yet released. Wait for the next release before publishing. Before publishing: - [x] Update Realm Swift to the release version - [x] Add links to the API reference docs ### Jira - https://jira.mongodb.org/browse/DOCSP-34055 ### Staged Changes - [Manage Sync Sessions](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-34055/sdk/swift/sync/sync-session/#wait-for-changes-to-upload-or-download) ### 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 ### Release Notes - **Swift SDK** - Sync Data/Manage Sync Sessions: New "Wait for Changes to Upload or Download" section with Bluehawked, tested code examples. ### Review Guidelines [REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)
- Loading branch information
Showing
9 changed files
with
211 additions
and
9 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
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: 16 additions & 0 deletions
16
source/examples/generated/code/start/Sync.snippet.awaitable-wait-for-upload-download.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,16 @@ | ||
// Wait to download all pending changes from Atlas | ||
try await realm.syncSession?.wait(for: .download) | ||
|
||
// Add data locally | ||
try realm.write { | ||
realm.create(Task.self, value: [ | ||
"taskName": "Review proposal", | ||
"assignee": "Emma", | ||
"completed": false, | ||
"progressMinutes": 0, | ||
"dueDate": date | ||
]) | ||
} | ||
|
||
// Wait for local changes to be uploaded to Atlas | ||
try await realm.syncSession?.wait(for: .upload) |
25 changes: 25 additions & 0 deletions
25
source/examples/generated/code/start/Sync.snippet.callback-wait-for-upload-download.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,25 @@ | ||
// Wait to download all pending changes from Atlas | ||
realm.syncSession?.wait(for: .download, block: { _ in | ||
// You can provide a block to execute | ||
// after waiting for download to complete | ||
}) | ||
|
||
// Add data locally | ||
do { | ||
try realm.write { | ||
realm.create(Task.self, value: [ | ||
"taskName": "Review proposal", | ||
"assignee": "Emma", | ||
"completed": false, | ||
"progressMinutes": 0, | ||
"dueDate": date | ||
]) | ||
} | ||
} catch { | ||
print("There was an error writing to realm: \(error.localizedDescription)") | ||
} | ||
// Wait for local changes to be uploaded to Atlas | ||
realm.syncSession?.wait(for: .upload, block: { _ in | ||
// You can provide a block to execute after | ||
// waiting for upload to complete | ||
}) |
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