Coder Social home page Coder Social logo

andrewbarba / bluebird.swift Goto Github PK

View Code? Open in Web Editor NEW
41.0 3.0 2.0 677 KB

Promise/A+, Bluebird inspired, implementation in Swift 5

License: MIT License

Swift 98.54% Ruby 0.76% Makefile 0.44% C 0.26%
bluebird swift async control-flow promise concurrency

bluebird.swift's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bluebird.swift's Issues

Using with Swift package manager

I tried to import Bluebird into command line app using Swift package manager. It wouldn't compile and was giving following error:

error: use of undeclared type 'DispatchQueue'

I had to add "import Foundation" to all Bluebird's files to make it compile. Is there any reason why it was omitted? Did I miss some configuration? Meanwhile Alamofire compiled right away..

Promise<Void>.resolve()

Hi there! At first I'd like to say that you did a great job creating this promise framework!
I'm thinking on migrating from closure-style async API to promise-style, and I need your help here.

Sometimes needed to not pass any argument in a resolve block of promise, this is where Promise appears. Whenever I call resolve() on such promise, it requires an arguments, which doesn't make sense.
What I'm asking for is: can you please add a function with signature without any parameter for void-parametrized promise? Thanks in advance.

Related image: https://imgur.com/fGtH99j

Finalize catch/then semantics

One of the hardest challenges of a Promise implementation in a strongly typed language is the semantics of catch and how it affects the Promise chain:

Promise/A+ 2.2.7.1
If either onFulfilled or onRejected returns a value x, run the Promise Resolution Procedure Resolve(promise2, x)

With this requirement, any then called directly after a catch does not know the Type of the first argument in it's handler. If the prior Promise resolves, then it will be the resolution of that Promise, but if it rejects it will be whatever value the catch returns. This unknown makes it impossible to implement directly in a typed language and forces us to make tradeoffs either with more functions (different names that explicitly indicate which behavior they implement) or making the resolution type less strict perhaps by using an optional type or a Any and then forcing unwrapping in the then handler.

I'm curious what the community's thoughts are on this before changing the semantics again in this library. If/when there is a good solution I will release a new version of the library as 2.0.0.

For reference, the current implementation provides 2 functions: catch and catchThen:

  • catch allows for catching an error and continuing the promise chain as Promise<Void>. Whether the prior promise resolves/rejects, the then handler after a catch will always be run.
  • catchThen forces the handler to recover with the same result Type as the original Promise. This means that if the original Promise resolves we can pass that result down to any then handlers after the catch and if it rejects the catch will be responsible for providing an alternate resolution of the same type.

Carthage Bluebird.swift framework is missing CFBundleVersion

Carthage Bluebird.swift framework (Bluebird.framework/Info.plist) is missing CFBundleVersion.

From CFBundleVersion:

This key is required by the App Store and is used throughout the system to identify the version of the build. For macOS apps, increment the build version before you distribute a build.

ITMS error with framework bundled in App.app/Frameworks via Carthage:

ERROR ITMS-90056: "This bundle Payload/App.app/Frameworks/Bluebird.framework is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"

Q: How to create a pending Promise?

RT.

I'm writing code to wrap the delegation pattern to Promise.

Can I create a pending promise?

I'm new to Promise/Future Programming, and I find it is not obvious to create a pending promise with Bluebird.swift.

Some other problems:
How to get value 1 & value 2 in the 3rd `then closure?

Missing support for binary frameworks with module stability

Bluebird.xcodeproj isn't configured to generate a .swiftinterface file which means dynamic frameworks can only be used with projects using the same version of the Swift compiler.

It would be nice to not have to recompile the framework when a new Swift compiler is released.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.