قالب وردپرس درنا توس
Home / IOS Development / Newbie Question on Threads + PromiseKit: iOSProgramming

Newbie Question on Threads + PromiseKit: iOSProgramming



I'm new to PromiseKit.

I had some wrappers around asynchronous catches that made sure that the finisher would be called on the main thread. Now, with PromiseKit, I do not know what is the most directly appropriate way to do it.

My current "solution" uses the tube function:

  func fetchRecords (with query: CKQuery,
InZone zoneID: CKRecordZone.ID) -> Promise <[CKRecord]>
{
return promise {resolver in
self.database.perform (query, inZoneWith: zoneID). pip {result in
DispatchQueue.main.async {resolver.resolve (result)}
}
}
}

Is there a better way that might be more in line with PromiseKit + Queues?


Source link