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

Performing work on non-main queue. #9

Open
cjmconie opened this issue Jul 17, 2020 · 1 comment
Open

Performing work on non-main queue. #9

cjmconie opened this issue Jul 17, 2020 · 1 comment
Labels
query General QnA

Comments

@cjmconie
Copy link

What is the correct way of performing work on a non-main queue using CombineFirebase?

For example, using .getDocument(as:) to transform the data into a model object (in this case City). From the Combine docs it looks like adding subscribe(on:) should ensure the upstream operations are performed on the specified scheduler.
However, when debugging it looks like this is not the case. Is there an issue with my code, or is it related to the implementation of this library? Thanks.

func getDocumentAsObject() {
    db.collection("cities")
        .document("SF")
        .getDocument(as: City.self)
        .subscribe(on: DispatchQueue.global(qos: .userInitiated)) // move upstream work onto non-main thread...
        .sink(receiveCompletion: { (completion) in
               switch completion {
               case .finished: print("🏁 finished")
               case .failure(let error): print("❗️ failure: \(error)")
               }
           }) { city in
               print("City: \(city)")
        }
        .store(in: &cancelBag)
}
@alexfringes
Copy link

Just passing through and got curious about this issue. Was wondering if the answer here regarding forcing things to the background queue happens to be of value: https://stackoverflow.com/a/58898411/2640516

@kshivang kshivang added the query General QnA label Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
query General QnA
Projects
None yet
Development

No branches or pull requests

3 participants