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

PromiseKit optional chaining Swift

How I can make Optional promises chaining? e.g., I have two promises and I have to check second only by some conditions from first promise results. promise1(). then { result -> Promise? in if result.success { return promise2() } return nil } .then {…
Roman Volkov
  • 245
  • 1
  • 4
  • 12
0
votes
1 answer

ios - How to mock a method with pmkpromise as the return type

I have method which I want to unit test: - (void)fetchInfo { [AMKAccountService getInfo] .then(^(AMKInfoResponse *response) { if (response.accounts.count > 0) { _viewModel = [[AMKInfoViewModel alloc] initWithInfoResponse:response]; …
0
votes
1 answer

Wait for promise to return

I want to asynchronously load some data when my app starts and use the loaded data from a view controller that's presented later on in the apps' flow. How do I determine if the data has loaded and, if it hasn't, how do I wait for it to load? So if…
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
0
votes
1 answer

Error calling "fulfill" from closure

Here's my error... Thread 1: EXC_BAD_ACCESS (code=1, address=0x18) Here is my product request delegate... class ProductRequestDelegate : NSObject, SKProductsRequestDelegate { private var products: ([SKProduct]) -> Void init(products:…
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
0
votes
2 answers

How to natively avoid the nesting block for multiple async tasks which must be executed one after the completion of another

Here is the case: There are more than 3 async tasks. Each one can only be executed after the completion of the previous one. Yes, must be after the completion of the previous one. That's why dispatch group might not be good for this case because it…
fans3210
  • 209
  • 2
  • 9
0
votes
2 answers

While Loop increments and re-runs before Promisekit can finish running and return the proper value in Swift

I'm trying to use a while loop with Promisekit with Alamofire to chain four GET requests, return a value, and rerun the four requests with a new parameter. This is the current code that I'm using: var index = 0 var count =…
Dominic
  • 95
  • 1
  • 1
  • 14
0
votes
1 answer

PromiseKit branching promise

Suppose you have a branch in your promise chain that could either return nothing or an AnyObject promise. What would you specify as the return type of the 'then' closure? For example: func sample() -> Promise { return Promise {…
rclark
  • 301
  • 3
  • 13
0
votes
1 answer

PromiseKit segmentation fault: 11

I'm trying to get a basic promise working with PromiseKit. However the following code wont compile: import Foundation import PromiseKit class MyClass { var myInt: Int? func sample() -> Promise { return Promise { fulfill,…
rclark
  • 301
  • 3
  • 13
0
votes
1 answer

How to refactor swift callback to promise with PromiseKit

I am attempting my first foray into swift promises with PromiseKit, after some experience with doing them with bluebird in node. My original service function for authentication with a callback looks like this: private func requestNewToken(email :…
Eric H
  • 1,323
  • 3
  • 14
  • 29
0
votes
1 answer

Swift - didReceiveRemoteNotification - PromiseKit

Can I use PromiseKit in AppDelegate - application:didReceiveRemoteNotification method? I am using GCM to push notification from the server. Once the app receives the notification I would like to fetch some data from the server, parse it, massage it…
imme
  • 299
  • 1
  • 4
  • 8
0
votes
1 answer

Has "when" been renamed in PromiseKit 3 for Swift2?

I am wondering why I can't get this example from the documentation of PromiseKit running: http://promisekit.org/when/ I have found out that .catch has been renamed to .error, and .finally has been renamed to .always, but what about "when"? Or am I…
Christian Anton
  • 357
  • 1
  • 4
  • 13
0
votes
0 answers

Black screen during requests for ios 9 - PromiseKit?

When I updated xCode and build on iOs 9, during all my synchronisation requests, my screen is black. It is working, but it seems that threads are not handled the same way. I am using AFNetworking and PromiseKit pods. I did not updated PromiseKit …
Manon
  • 44
  • 5
0
votes
0 answers

Does the Parse query download the same object multiple times?

Im beginning to scratch the surface of Swift, Parse and IOS, and I had a question regarding how parse performs its findObjectsInBackgroundWithBlock method In the little snippet below, can someone tell me, if my app will continuously keep downloading…
7hacker
  • 1,928
  • 3
  • 19
  • 32
0
votes
1 answer

Chaining promises in Alamofire using Promisekit

I think this is a pretty common use case, but I couldn't find any best way to achieve it. Some parts of my ios application require login. How do I achieve the following pattern using Alamofire and swift. .request (.GET 'login_required_endpoint') …
user462455
  • 12,838
  • 18
  • 65
  • 96
0
votes
1 answer

Collect array of successful promises

I'm using PromiseKit 3.0 in Swift and I have an array of promises [Promise]. I want to gather up all the promises that succeed into a single promise. Promise<[Int]>. Both when and join reject if even one contained promise rejects. According to…
Daniel T.
  • 32,821
  • 6
  • 50
  • 72