Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.

Comments
  • Application not compiling on XCode 10 and on iOS 12 device

    Application not compiling on XCode 10 and on iOS 12 device

    There seems to be an issue while converting Promise to FBLPromise. Completly blocked.

    1. While generating Objective-C header
    2. While printing 'Connection' at /Volumes/Official/WorkingCopy/native/Classes/Swift/Connection/Connection.swift:11:1
    3. While printing type 'Promise.ObjCPromise'
    4. While printing type 'Value' error: Segmentation fault: 11
    opened by rajesht1989 26
  • FBLPromises.framework confusion

    FBLPromises.framework confusion

    I'm a little confused about what FBLPromises.framework is, and whether I need to link & embed it. I'm using Carthage and Swift, no objc.

    When I link and embed the Carthage-built Promises.framework, everything builds fine but it crashes on launch with:

    dyld: Library not loaded: @rpath/FBLPromises.framework/Versions/A/FBLPromises
      Referenced from: /Users/jeffh/Library/Developer/Xcode/DerivedData/CMShell_Demo-byxhplkbtqxauhejbrbnapbkhdgi/Build/Products/Debug/CMShell Demo.app/Contents/Frameworks/Promises.framework/Versions/A/Promises
      Reason: image not found
    

    If I also embed and include the Carthage-built FBLPromises.framework then everything works just fine, but I don't want to be including stuff I shouldn't / don't need.

    Sorry if I'm doing something stupid. And thanks for this beautiful library, it really is a joy to use.

    opened by jeff-h 20
  • Swift version should be specified in the Podspec for `PromisesSwift` pod

    Swift version should be specified in the Podspec for `PromisesSwift` pod

    Getting this error when updating to PromisesSwift 1.2.9 (cocoapods 1.9.3 and 1.10.0.beta.1):

    [!] Unable to determine Swift version for the following pods:
    
    - `PromisesSwift` does not specify a Swift version and none of the targets (`Dummy`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
    
    opened by edudnyk 18
  • CancelToken for promise completion blocks

    CancelToken for promise completion blocks

    Promises should have ability to remove registered fulfillment/rejection callbacks(blocks) WITHOUT influencing underlying operation that promise corresponds to.

    Such CancelToken (often also called InvalidationToken) should also allow cancellation of callback scheduled on some queue from within the same queue, just in earlier block. In other words, cancellation of callback should work even if its block is already scheduled on the queue (but not yet started to execute).

    opened by virl 18
  • waitForPromises() should be removed

    waitForPromises() should be removed

    waitForPromises() should be removed because it is an abstraction leak: you never know in the test what other promises tested code will use in it internal implementation.

    "So waiting for a bunch of async tasks to finish in a test can be tricky." (from docs) — no, it is tricky on Android that doesn't have any SDK support for it.

    On iOS, we have XCTestExpectation exactly for that, without false hope for tested code to move into predictable state by leaking its implementation details into the test.

    opened by virl 14
  • Bug in iOS 16 DevBeta1

    Bug in iOS 16 DevBeta1

    https://github.com/google/promises/blob/46c1e6b5ac09d8f82c991061c659f67e573d425d/Sources/Promises/Promise%2BAsync.swift#L28 String can convert to NSError in iOS 16. This most likely is a bug in iOS 16. Hope Apple could fix this soon.

    opened by mlch911 13
  • Unable to find a specification

    Unable to find a specification

    I am trying to install this with cocoapods

    I first set (as per doc) in my podfile,

    pod 'PromisesObjC', '~> 1.2.3'

    it gave me following error

    Unable to find a specification for PromisesObjC (~> 1.2.3)

    Then I tried with pod 'PromisesObjC'

    it gave me following error

    Unable to find a specification for PromisesObjC

    I am using xcode 9.4

    opened by chiragpurohit71085 11
  • Promise<String> fulfil not working as expected

    Promise fulfil not working as expected

    Hi, while writing some code I start noticing that a catch block was called even if the promise was fulfil. The catch was called in a complex chain so in the attempt to find the problem I reduced my code to:

        public func test() -> Promise<String> {
            return Promise<String> { fulfil, _ in
                fulfil("String")
            }
        }
    

    called as follow:

            controller.test().then { (string) in
                print("result: \(string)")
            }.catch { (error) in
                print("Error: \(error.localizedDescription)")
            }
    

    Running the above I get Error: The operation couldn’t be completed. (Swift.String error 1.)

    I tracked down where promises decides that the above is an error to: Promise+Asynch.swift:28 where for some reason I truly don't understand if let error = value as? NSError generate a cast from String to NSError

    While changing the code above to

        public func test() -> Promise<NSString> {
            return Promise<NSString> { fulfil, _ in
                let string = String("12")
                fulfil(string as NSString)
            }
        }
    

    then the fulfil goes well and the .then is called

    I tried to reproduce the behaviour I see in my project in the Promises test suite without success.

    I don't understand what is going on here, any help is appreciated.

    opened by lucabartoletti 10
  • Anyone seeing this asObjCPromise swiftc crash in Xcode 11

    Anyone seeing this asObjCPromise swiftc crash in Xcode 11

    for this method:

      @objc
      public func allFoo() -> Promise<NSArray>.ObjCPromise<NSArray>
      {
        return promiseSwiftArrayOfFoo().then { $0 as NSArray }.asObjCPromise()
      }
    

    Crashes swiftc with:

    Showing All Messages

    1.	While generating Objective-C header [redacted]
    2.	While printing 'TheClass' at [redacted]/TheClass.swift:14:8
    3.	While printing type 'Promise<NSArray>.ObjCPromise<NSArray>'
    4.	While printing type 'Value'
    

    Update, the original code which also crashes (I thought the above might be simpler for the type mangler to resolve):

      @objc
      public func allFoo() -> Promise<[Foo]>.ObjCPromise<NSArray>
      {
        return promiseSwiftArrayOfFoo().asObjCPromise()
      }
    
    opened by aufflick 10
  • What is the best way to retry a promise?

    What is the best way to retry a promise?

    On the readme is says that using promises makes it easier to retry asynchronous operations. I couldn't find a retry method or anything of the sort, so what would be the simplest way to retry an operation using promises?

    Thanks.

    opened by hpbl 9
  • Fix Xcode Swift 5 conversion warning

    Fix Xcode Swift 5 conversion warning

    After the update to Swift 5 the swift_version was deleted from PromisesSwift.podspec (70c337e196c81f795eedb5d7a42cf966f07cdc3d). But now, Xcode keeps showing the "Conversion to Swift 5 is available" warning:

    Screenshot 2019-07-07 at 19 03 40

    Putting it back will make the warning disappear.

    opened by AnderGoig 8
  • Ignore a certain Error and terminate Promise

    Ignore a certain Error and terminate Promise

    Is there any way to completely ignore an Error? For example, when I reject a Promise with something like PromiseCancelledError, I don't want the downstream catches to handle this error. I want the Promise to be terminated and produce no output at all. Both catch and recover are not working for this case.

    opened by kientux 2
  • Question regarding implementation

    Question regarding implementation

    Hi I have looked through the code and was wondering about some parts of it, I would really appreciate if you could share some light when creating a promise with the following code: link

    + (instancetype)onQueue:(dispatch_queue_t)queue async:(FBLPromiseAsyncWorkBlock)work {
      NSParameterAssert(queue);
      NSParameterAssert(work);
    
      FBLPromise *promise = [[self alloc] initPending];
      dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
      work(
            ^(id __nullable value) {
              if ([value isKindOfClass:[FBLPromise class]]) {
                [(FBLPromise *)value observeOnQueue:queue
                    fulfill:^(id __nullable value) {
                      [promise fulfill:value];
                    }
                    reject:^(NSError *error) {
                      [promise reject:error];
                    }];
              } else {
                [promise fulfill:value];
              }
            },
            ^(NSError *error) {
              [promise reject:error];
            });
      });
      return promise;
    }
    
    1. What is the purpose of dispatch_group_async(FBLPromise.dispatchGroup? I mean why dispatch_group_async what the purpose of groupes (I feel it like synchronizes the calls )
    2. if the queue was asynchronous (not serial by default) what guarantee that work will be executed after the calling code
    opened by MikePendo 3
  • Confused when retry a Promise variable

    Confused when retry a Promise variable

    With the example in the doc, https://github.com/google/promises/blob/master/g3doc/index.md#retry

    retry method wraps a method that always returns a new Promise, so when the Promise of the first time method failed, retry will call the fetch method again and create a new Promise, and all work perfectly.

    But if retry a Promise variable, things get wired.

    let p = Promise<Int> { resolve, reject in
        print("promise")
        reject(NSError(domain: "promise", code: 1, userInfo: nil))
    }
    
    retry {
        p
    }.then { _ in
        print("then")
    }.catch { _ in
        print("catch")
    }
    

    code wrapped by Promise p will only run once, not twice, does this is a bug or feature?

    opened by EkkoG 0
  • ios 16 strings convertible to NSError

    ios 16 strings convertible to NSError

    In iOS 16 string are convertible to NSError and because of this promises are getting rejected. Kindly check the line number 28 in below URL where issue is occurring .

    https://github.com/google/promises/blob/46c1e6b5ac09d8f82c991061c659f67e573d425d/Sources/Promises/Promise%2BAsync.swift

    opened by ganesh7845 1
  • Objective-C Promises crashes in SwiftUI previews

    Objective-C Promises crashes in SwiftUI previews

    When statically linked, the Promises categories don't get linked and apps crash in Swift UI previews.

    A workaround may be to add a symbol to the category implementation files that is referenced from a non-category file.

    See https://github.com/firebase/firebase-ios-sdk/issues/8005 and https://github.com/firebase/firebase-ios-sdk/issues/9916

    opened by paulb777 1
Releases(2.0.0)
Owner
Google
Google ❤️ Open Source
Google
A Swift based Future/Promises Library for IOS and OS X.

FutureKit for Swift A Swift based Future/Promises Library for IOS and OS X. Note - The latest FutureKit is works 3.0 For Swift 2.x compatibility use v

null 759 Dec 2, 2022
Write great asynchronous code in Swift using futures and promises

BrightFutures How do you leverage the power of Swift to write great asynchronous code? BrightFutures is our answer. BrightFutures implements proven fu

Thomas Visser 1.9k Dec 20, 2022
Lightweight promises for iOS, macOS, tvOS, watchOS, and Linux

Futures Futures is a cross-platform framework for simplifying asynchronous programming, written in Swift. It's lightweight, fast, and easy to understa

David Ask 60 Aug 11, 2022
Futures and Promises library

#PureFutures A simple Futures and Promises library. ##Installation ###Carthage Add the following in your Cartfile: github "wiruzx/PureFutures" And ru

Victor Shamanov 17 Apr 5, 2019
Promises for Swift & ObjC.

Promises simplify asynchronous programming, freeing you up to focus on the more important things. They are easy to learn, easy to master and result in

Max Howell 14k Jan 5, 2023
When is a lightweight implementation of Promises in Swift.

Description When is a lightweight implementation of Promises in Swift. It doesn't include any helper functions for iOS and OSX and it's intentional, t

Vadym Markov 260 Oct 12, 2022
FutureLib is a pure Swift 2 library implementing Futures & Promises inspired by Scala.

FutureLib FutureLib is a pure Swift 2 library implementing Futures & Promises inspired by Scala, Promises/A+ and a cancellation concept with Cancellat

Andreas Grosam 39 Jun 3, 2021
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift

Lightweight full-featured Promises, Async & Await Library in Swift What's this? Hydra is full-featured lightweight library which allows you to write b

Daniele Margutti 2k Dec 31, 2022
Easy Swift Futures & Promises.

❗️ Archived now ❗️ Since Apple released Combine framework, I decide to archive this repo. You still can use this repo as an example of Future/Promise

Dmytro Mishchenko 40 Sep 23, 2022
A promises library written in Swift featuring combinators like map, flatMap, whenAll, whenAny.

Promissum is a promises library written in Swift. It features some known functions from Functional Programming like, map and flatMap. It has useful co

Tom Lokhorst 68 Aug 31, 2022
Tame async code with battle-tested promises

Then Reason - Example - Documentation - Installation fetchUserId().then { id in print("UserID : \(id)") }.onError { e in print("An error occur

Fresh 963 Jan 3, 2023
A light-weighted Promise library for Objective-C

RWPromiseKit Desiciption A light-weighted Promise library for Objective-C About Promise The Promise object is used for deferred and asynchronous compu

Canopus 113 May 4, 2022
Publish–subscribe design pattern implementation framework, with an ability to publish events by topic.

TopicEventBus Publish–subscribe design pattern implementation framework, with ability to publish events by topic. (NotificationCenter extended alterna

Matan Abravanel 55 Nov 29, 2021
A Protocol-Oriented NotificationCenter which is type safe, thread safe and with memory safety

A Protocol-Oriented NotificationCenter which is type safe, thread safe and with memory safety. Type Safe No more userInfo dictionary and Downcasting,

null 632 Dec 7, 2022
A dead-simple abstraction over the iOS BackgroundTask API to make background tasks easy to isolate, maintain and schedule

A dead-simple abstraction over the iOS BackgroundTask API to make background tasks easy to isolate, maintain and schedule. Designed to be as lightweight and flexible as possible while tightly integrating with the system APIs. And It's built with Swift Concurrency in mind.

Sam Spencer 31 Dec 11, 2022
Promise + progress + pause + cancel + retry for Swift.

SwiftTask Promise + progress + pause + cancel + retry for Swift. How to install See ReactKit Wiki page. Example Basic // define task let task = Task<F

ReactKit 1.9k Dec 27, 2022
Promise/A+, Bluebird inspired, implementation in Swift 5

Bluebird.swift Promise/A+ compliant, Bluebird inspired, implementation in Swift 5 Features Promise/A+ Compliant Swift 5 Promise Cancellation Performan

Andrew Barba 41 Jul 11, 2022
A Promise library for Swift, based partially on Javascript's A+ spec

Promise A Promise library for Swift, based partially on Javascript's A+ spec. What is a Promise? A Promise is a way to represent a value that will exi

Soroush Khanlou 622 Nov 23, 2022
Material para a apresentação da palestra "Implementando Interesses Transversais - um papo sobre arquitetura, DI e Design Patterns em Swift/iOS" no TDC Future 2021

--- title: Implementando Interesses Transversais - um papo sobre arquitetura, DI e Design Patterns em Swift/iOS author: Cícero Camargo date: Nov 30th

Cícero Camargo 2 Nov 30, 2021