Questions tagged [promisekit]

PromiseKit is Objective-C and Swift Promises implementation. It is also a collection of helper functions that make the typical asynchronous patterns we use in iOS development delightful too.

Modern development is highly asynchronous: isn’t it about time iOS developers had tools that made programming asynchronously powerful, easy and delightful?

PromisesKit is not just a Promises implementation, it is also a collection of helper functions that make the typical asynchronous patterns we use in iOS development delightful too.

In addition, PromisesKit is designed to be integrated into other CocoaPods. If your library has asynchronous operations then consider adding an opt-in subspec that provides Promises for your users. Documentation to help you integrate PromiseKit into your own pods is provided later in this guide.

PromisesKit is available in Objective-C and Swift flavors.

241 questions
2
votes
1 answer

Update to Xcode 12: Cannot convert value of type 'DataRequest' to closure result type 'Void'

I am using AlamoFire and PromiseKit to do API calls. The code was working fine for 2 years until I updated to Xcode 12.0. Function now returning the error: "Cannot convert value of type 'DataRequest' to closure result type 'Void'" My function is as…
Sinan Noureddine
  • 495
  • 5
  • 16
2
votes
2 answers

Cannot convert value of type '(Void) -> ()' to expected argument type '() -> Void'

I am trying to implement the TradeIt ios SDK and I am not able to compile due to issues in the sdk. let promises = self.getAllDisplayableLinkedBrokers().map { linkedBroker in return Promise { seal in …
2
votes
1 answer

PromiseKit: calling when(fulfilled:) with array of different type of Promise

I have an array of Promise of different type. In this particular case Promise and Promise which I want to provide to when(fulfilled:) As an example: let fileName = "somefilename" let videos: [URL] = selectedItems.compactMap { guard…
superandrew
  • 1,741
  • 19
  • 35
2
votes
2 answers

How to map Promise to Guarantee?

I have a Promise that I would like to transform into a Guarantee where true means the promise fulfilled and false if it got rejected. I managed to reach this using return getPromise() .map { _ in true } .recover { _ in…
Raphael Oliveira
  • 7,751
  • 5
  • 47
  • 55
2
votes
2 answers

PromiseKit `Result.. is unused warning` in a chained sequence with a for loop

I have this annoying warning and I'm not able to get rid of it. Let's say that I have a promise that sends a command to a bluetooth le device, to do a procedure I need to send these commands synchronously. So what you can do in PromiseKit 6 is…
Andrea
  • 26,120
  • 10
  • 85
  • 131
2
votes
1 answer

JSONSerialization.jsonObject isn't accepting my parameters

I'm attempting to Promise a Json object. However, JSONSerialization.jsonObject isn't accepting any of my parameters.. class func deserialize(data: Data) -> Promise { let deserialized = try! JSONSerialization.jsonObject(with: data, options:…
Konrad Wright
  • 1,254
  • 11
  • 24
2
votes
1 answer

Caching in Swift 4.2 using PromiseKit 6

I'm experiencing two errors: pending = endpoint().then { freshValue in Causes error: "Unable to infer complex closure return type; add explicit type to disambiguate" return Guarantee(cachedValue) as! Guarantee Causes error: "Cannot convert…
Konrad Wright
  • 1,254
  • 11
  • 24
2
votes
1 answer

PromiseKit wrapping external closure in Promises

I am using an external library in Swift so I cannot control the return statements. My understanding is that I should wrap these returns in promises in order to use PromiseKit. Is this correct? Assuming so, I have working code as follows: private…
AlexK
  • 336
  • 8
  • 21
  • 41
2
votes
1 answer

PromiseKit firstly around code, not function call

I don't want to write a separate function to return a Promise in my firstly call. I just want to write this: firstly { return Promise { inSeal in var isOrderHistory = false let importTester = CSVImporter(url:…
Rick
  • 3,298
  • 3
  • 29
  • 47
2
votes
1 answer

Correctly chain multiple promises in PromiseKit 6

I'm using Promisekit 6 and have 3 functions defined, all of which return promises. the first fetches data from a local database and the second from an online API server. the third, Foo, checks if the data with a given id exists locally, otherwise it…
SamAko
  • 3,485
  • 7
  • 41
  • 77
2
votes
1 answer

Cannot convert value of type 'Promise<[NSDictionary]>' to expected argument type 'Guarantee'

Currently, I'm having issues when I updated my PromiseKit from Swift 2 to Swift 4. A lot of my Promises are returning this issue from NSDictionary to Guarantee Void. I don't understand why this issue arises. If someone could explain it to me, that'd…
Konrad Wright
  • 1,254
  • 11
  • 24
2
votes
0 answers

Multiple asynchronous tasks with PromiseKit

I have a form for a user to change his address. This form contains two checkboxes. The user can choose if he wants to save the form as billing address, shipping address or both. The both-part is giving me trouble. The PromiseKit…
Tobias Grunwald
  • 161
  • 1
  • 3
  • 14
2
votes
1 answer

Chaining Alamofire requests with Swift and PromiseKit

I have 2 API endpoints; the latter depends on the result of the first. The first end point is /api/v1/regions/, which returns a list of region JSON like so { region_id: 1, mayor_id: 9 }, { region_id: 1, mayor_id: 10 }, The second end point…
7ball
  • 2,183
  • 4
  • 26
  • 61
2
votes
1 answer

Returning promise that uses another promise with PromiseKit

Here's an example of the code this question is about: func executeTask() { fetchApiData().then { foos in return filterData(foos) }.then { foos in return saveData(foos) }.catch { /** handle error **/ …
TRG
  • 845
  • 1
  • 9
  • 22
2
votes
2 answers

How to ensure two asynchronous tasks that 'start' together are completed before running another?

I am setting up an app that utilizes promiseKit as a way to order asynchronous tasks. I currently have a set up which ensures two async functions (referred to as promises) are done in order (lets call them 1 and 2) and that another set of functions…
Runeaway3
  • 1,439
  • 1
  • 17
  • 43