Repository: realm/realm-swift
File: RealmSwift/App.swift (Swift)

Code before:
    /// If the json can not be successfully serialised and error will be produced and the object will be nil.
    case function(payload: Document)
    /// Credentials from a user api key.
    case userAPIKey(String)
    /// Credentials from a sever api key.
    case serverAPIKey(String)
    /// Represents anonymous credentials
    case anonymous
}

/// The `App` has the fundamental set of methods for communicating with a Realm
/// application backend.
/// This interface provides access to login and authentication.
public typealias App = RLMApp

public extension App {
    /**
    Updates the base url used by Atlas device sync, in case the need to roam between servers (cloud and/or edge server).
     - parameter url: The new base url to connect to. Setting `nil` will reset the base url to the default url.
     - parameter completion: A callback invoked after completion.
     - note: Updating the base URL would trigger a client reset.
     */
    @preconcurrency
    @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    @_spi(RealmSwiftExperimental) func updateBaseUrl(to url: String?, _ completion: @Sendable @escaping (Error?) -> Void) {
        self.__updateBaseURL(url, completion: { error in
            completion(error)
        })
    }

    /**
     Login to a user for the Realm app.
     
     - parameter credentials: The credentials identifying the user.
     - parameter completion: A callback invoked after completion. Will return `Result.success(User)` or `Result.failure(Error)`.
     */
    @preconcurrency
    func login(credentials: Credentials, _ completion: @Sendable @escaping (Result<User, Error>) -> Void) {
        self.__login(withCredential: ObjectiveCSupport.convert(object: credentials)) { user, error in
            if let user = user {
                completion(.success(user))
            } else {
                completion(.failure(error ?? Realm.Error.callFailed))
            }
        }
    }

    /**
    Updates the base url used by Atlas device sync, in case the need to roam between servers (cloud and/or edge server).
     - parameter url: The new base url to connect to. Setting `nil` will reset the base url to the default url.
     - parameter completion: A callback invoked after completion. Will return `Result.success` or `Result.failure(Error)`.

Review comment (suggestion):
Shouldn't need to wrap the completion block here since it's the same type.

Code after:
    /// If the json can not be successfully serialised and error will be produced and the object will be nil.
    case function(payload: Document)
    /// Credentials from a user api key.
    case userAPIKey(String)
    /// Credentials from a sever api key.
    case serverAPIKey(String)
    /// Represents anonymous credentials
    case anonymous
}

/// The `App` has the fundamental set of methods for communicating with a Realm
/// application backend.
/// This interface provides access to login and authentication.
public typealias App = RLMApp

public extension App {
    /**
    Updates the base url used by Atlas device sync, in case the need to roam between servers (cloud and/or edge server).
     - parameter url: The new base url to connect to. Setting `nil` will reset the base url to the default url.
     - parameter completion: A callback invoked after completion.
     - note: Updating the base URL would trigger a client reset.
     */
    @preconcurrency
    @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    @_spi(RealmSwiftExperimental) func updateBaseUrl(to url: String?, _ completion: @Sendable @escaping (Error?) -> Void) {
        self.__updateBaseURL(url, completion: completion)
    }

    /**
     Login to a user for the Realm app.
     
     - parameter credentials: The credentials identifying the user.
     - parameter completion: A callback invoked after completion. Will return `Result.success(User)` or `Result.failure(Error)`.
     */
    @preconcurrency
    func login(credentials: Credentials, _ completion: @Sendable @escaping (Result<User, Error>) -> Void) {
        self.__login(withCredential: ObjectiveCSupport.convert(object: credentials)) { user, error in
            if let user = user {
                completion(.success(user))
            } else {
                completion(.failure(error ?? Realm.Error.callFailed))
            }
        }
    }

    /**
    Updates the base url used by Atlas device sync, in case the need to roam between servers (cloud and/or edge server).
     - parameter url: The new base url to connect to. Setting `nil` will reset the base url to the default url.
     - parameter completion: A callback invoked after completion. Will return `Result.success` or `Result.failure(Error)`.
     - note: Updating the base URL would trigger a client reset.
     */