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
3
votes
1 answer

How to use Loop in PromiseKit 6?

I have a function called chaining which chains multiple promises and I want to call that function multiple times. For that, I am using a for loop and I want that with index 0, the chaining function should be executed with index 0. (I have an array…
Coder
  • 508
  • 2
  • 13
3
votes
2 answers

Get first response object in PromiseKit then done block

I'm calling three services in a row. When I'm calling third service, I need to use variable from first service response which is userModel. I can get second service response from which is initModel but can't reach first model userModel. My Question…
Emre Önder
  • 2,408
  • 2
  • 23
  • 73
3
votes
1 answer

PromiseKit: resolve method requires String and Void be equivalent

I'm trying to use PromiseKit v6 in iOS Swift 5 app but I trip on a very basic issue. The code below throws a compiler error: let p1 = Promise { seal in seal.resolve("Foo"); /// Referencing instance method 'resolve' on 'Resolver' …
konrad
  • 1,664
  • 2
  • 17
  • 36
3
votes
2 answers

PromiseKit w/ URLSession

I am trying to add a check against the response status code in the event my remote service returns a 401. I have am trying to use the PromiseKit URLSession extension. Imagine I have something basic such as return firstly { …
Teddy K
  • 820
  • 1
  • 6
  • 17
3
votes
1 answer

Migrating from PromiseKit wrap

I'm trying to get rid of some warnings in my code and can't seem to migrate away from PromiseKit's wrap. Specifically, in 6.0 the release details say I shouldn't use it and should use init(resolver:) instead. I had a function: func foo(arg1: Int,…
wizplum
  • 427
  • 5
  • 17
3
votes
1 answer

PromiseKit Cannot assign value of type '[Result]' to type '[TYPE]

Using PromiseKit, I am trying to set the output of the when block to the local variable allChatRooms var allChatRooms : [ChatRoom] var chatRoomIDs : [String:Bool] = ... firstly { when(resolved: chatRoomIDs.map{fetchChatRoom(id: $0.key)}) …
Entitize
  • 4,553
  • 3
  • 20
  • 28
3
votes
2 answers

Returning a Promise from a completion handler in PromiseKit

I have the following problem: func doSomething() -> Promise { let completionHandler = { (result: Bool) in // How can I fulfill the promise here -- Promise { fulfill, _ in fulfill(result) } } someLibrary.doSomeTasks(handler:…
7ball
  • 2,183
  • 4
  • 26
  • 61
3
votes
0 answers

How to cancel a long polling request with PromiseKit and Moya

I'm using PromiseKit and Moya to send a long polling request in the method bellow: func pullMessages() { let service = ChatServices() let request = service.pullMessages() self.request = request request.promise.then { [weak self]…
Zakaria
  • 1,040
  • 3
  • 13
  • 28
3
votes
1 answer

How to check if the multipart upload was successful with alamofire image

I am making a network call to upload an image to a backend server. Right now I am using the following to code. This code works perfectly in conditions where the internet is online. // MARK: - PUT static func PUT(URL: String, …
user5000215
3
votes
1 answer

How to set up when(fulfilled:) in PromiseKit?

I have a function set up to return a Promise. I would like to use this function in PromiseKit's when(fulfilled:) functionality, but whenever I try to do so, I get an error. Here is the function which returns the Promise: func…
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
3
votes
0 answers

Swift Alamofire + Promise catching

Folks, The following works except for the catch, xcode errors out with expected member name following '.' Is this the proper way to promisify with PromiseKit? All suggestions welcome! Thanks! @IBAction func loginButtonTapped(sender: AnyObject) { …
Cmag
  • 14,946
  • 25
  • 89
  • 140
3
votes
2 answers

PromiseKit 3.0 chaining

I'm trying to write a function that returns a promise: func sample() -> Promise { return Promise(1) .then { _ -> Void in debugPrint("foo") }.then { _ -> Void in debugPrint("foo") } } I get an error on the…
rclark
  • 301
  • 3
  • 13
3
votes
2 answers

Ambiguous use of recover error while using PromiseKit

Running into a strange error when using recover while handling errors that can be thrown while executing a promise. Chaining .recover with .then results in compilation if there is more than one statement in recover block. Having single statement in…
user462455
  • 12,838
  • 18
  • 65
  • 96
3
votes
1 answer

Bridging from Objective C to Swift with PromiseKit

Using PromiseKit 2.0 with Swift 1.2, I'm trying to use a PMKPromise that was created in Objective C from Swift. Objective C code: @interface FooTest : NSObject + (PMKPromise *)promise; @end Swift code (I've tried a number of variations, none of…
Tim Norman
  • 1,999
  • 1
  • 20
  • 26
3
votes
1 answer

iOS PromiseKit and CoreData NSManagedObjectContext

Having an NSManagedObjectContext with concurrency type NSPrivateQueueConcurrencyType can PromiseKit be used to prettify the performBlock:^{} / performBlockAndWait:^{} ? My first thought was to write like this : - (PMKPromise *)updateModel:(Model…
Daniel
  • 1,225
  • 2
  • 15
  • 31
1 2
3
16 17