Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress callback to asynchronous async await initialiser for Realm #8034

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dianaafanador3
Copy link
Collaborator

This is extending the API for Realm.init() async to have a callback for progress notifications. Feature request here #7763.

@cla-bot cla-bot bot added the cla: yes label Nov 16, 2022
@@ -1217,13 +1218,18 @@ extension Realm {
}
case .always:
rlmRealm = try await withCheckedThrowingContinuation { continuation in
RLMRealm.asyncOpen(with: configuration.rlmConfiguration, callbackQueue: .main) { (realm, error) in
let rlmTask = RLMRealm.asyncOpen(with: configuration.rlmConfiguration, callbackQueue: .main) { (realm, error) in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dianaafanador3 thanks for the PR. Looking good.

What was your reasoning for fixing the callbackQueue to .main rather than letting an implementer pass in their preffered queue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you can only run let realm = try await Realm() at the moment, in a @mainactor.
We are still discussing if this is the bet API for this, but we have a project in progress which should give better support for actor-confined Realms and offer a better experience with Swift concurrency in general, which should include exposing recurring callbacks as AsyncSequences for sync progress notification.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great, thanks @dianaafanador3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants