Cancel background db operation in Couchbase Lite iOS

I am using the Couchbase Lite iOS SDK with the language Swift. Many of my database operations run asynchronously (not all) by using the method :

CBLManager.sharedInstance().backgroundTellDatabaseNamed( {
// Background code block

Is it possible to cancel this operation? Or is there another way to run a background operation that is cancellable? Sometimes these database calls can take several seconds due to the mass amount of stored documents, and I need to cancel them under certain circumstances.

No, there’s nothing directly for this. You can have your block check an external boolean flag, and clear the flag from the main thread if you want to cancel the request. (Make sure the flag is atomic or otherwise thread-safe.)