andrewbarba / bluebird.swift Goto Github PK
View Code? Open in Web Editor NEWPromise/A+, Bluebird inspired, implementation in Swift 5
License: MIT License
Promise/A+, Bluebird inspired, implementation in Swift 5
License: MIT License
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..
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
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 (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"
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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.