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

Convert recursive async function to promise

I have a recursive, async function that queries Google Drive for a file ID using the REST api and a completion handler: func queryForFileId(query: GTLRDriveQuery_FilesList, handler: @escaping FileIdCompletionHandler) { …
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
2
votes
1 answer

PromiseKit with optional promises

I am currently investigating if I should integrate PromiseKit in an existing project. My main issue is that I need to implement a business logic that can call up to 5 web-services. Some of them are called depending on the result of previous ones. My…
2
votes
1 answer

How to utilize PromiseKit to ensure a queried object has been retrieved before proceeding?

I am programming an app which utilizes a parse-server (hosted by heroku) database. I have several functions which pull information from the DB, but they are all inherently asynchronous (because of the way parse's .findObjectinBackground works.) The…
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
2
votes
3 answers

PromiseKit pod installed correctly, but import PromiseKit returns error?

I am developing an app on Xcode 8.2.1 utilizing swift 3. I have a few asynchronous task that I need lined in an appropriate order and so I have decided to use PromiseKit for this purpose. I added a podfile to my project directory and modified then…
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
2
votes
1 answer

How to use PromiseKit/Photos?

How can I use PromiseKit/Photos any example? I am not able to find any docs for Photos in particular. I have implemented like below and i am able to receive request _ = PHPhotoLibrary.requestAuthorization().then(execute: { (status) -> Void in…
Parth Adroja
  • 13,198
  • 5
  • 37
  • 71
2
votes
2 answers

Swift - multiple Chain http request with loop

Since 2 days it feels that I'm searching the whole web to solve my problem with multiple http requests. So my workflow looks like this: Upload a image to a server Response = XML Format with a Task ID GET request to the server with the Task ID to…
kaaPe
  • 23
  • 4
2
votes
1 answer

Returning a Promise from PromiseKit/Alamofire

I'm trying to do this seemingly trivial thing: static func list() -> Promise<[Activity]> { let endpoint = "\(self.baseUrl)/v1/activities" return Promise { fulfill, reject in self.fetchHeaders { (headers) in return…
sssilver
  • 2,549
  • 3
  • 24
  • 34
2
votes
2 answers

iOS (ObjC) PromiseKit - Return promise within promise

I'm trying to cascade a promise through some classes which add functionality at each level. + (AnyPromise *) method { return [SomeClass whichReturnsPromise] .then(^(id obj){ // do stuff return obj; }); } Unfortunately…
smileham
  • 1,430
  • 2
  • 16
  • 28
2
votes
1 answer

PromiseKit - Return nested promise

I am trying to use PromiseKit, and am having a bit of trouble wrapping my head around this. I have a function that does something like func lengthyOperation() -> Promise { return Promise { fulfil, reject in …
georgemp
  • 716
  • 10
  • 21
2
votes
0 answers

Unit testing Alamofire + PromiseKit with Mockingjay

I have the following code in my project: import PromiseKit import SwiftyJSON class ChartHandler { var alamofireManager: Alamofire.Manager? init() { let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() …
Andrey M.
  • 3,021
  • 29
  • 42
2
votes
1 answer

PromiseKit: delegate-system wrappers seem to return immediately when not used at the beginning of the chain

I am fairly new to PromiseKit and I have been trying for a couple of days to figure out a solution for an unexpected behaviour of promise-wrapped delegate systems (UIALertView+PromiseKit, PMKLocationManager etc..). In my fairly typical scenario of…
2
votes
0 answers

How to unit test in PromiseKit?

Code of the test target is the following. - (PMKPromise *)fetchByUserId:(NSString *)userId { UserApiClient *user = [UserApiClient new]; return [user fetchByUserId:userId].then(^(UserEntity *entity) { // I want to test here. …
ko2ic
  • 1,977
  • 14
  • 20
2
votes
2 answers

What's the best Swift pattern for returning a pending PromiseKit promise if one is already in running?

I have some expensive promises that get called in different spots. Ideally, I'd like to just chain off an existing in-flight promise (with an optional force), so I find myself doing something like this: class Expensive { var fooPromise :…
Ryan
  • 606
  • 5
  • 12
2
votes
0 answers

Why does rejecting an Alamofire request with a custom error results in a PromiseKit: Unhandled Error: message

I am using the following: Alamofire (3.1.4) PromiseKit (3.0.0) xCode Version 7.2.1 (7C1002) I am rejecting an Alamofire request with the custom error below: Error is the struct that provides convenience methods for creating custom alamofire…
2
votes
1 answer

isKindOfClass returning nil inside PromiseKit?

My colleague and I are building an async data layer heavily based on PromiseKit v1.5.3. We've noticed in certain circumstances, when returning a promise (call it X) from a block passed to then, the next then block actually passes Promse X as the…
eriknelson
  • 849
  • 2
  • 11
  • 21