Skip to content
Promises for Swift & ObjC
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
PMKAlamofire.xcodeproj
Sources `responseDecodable(decoding: Foo.self)` Mar 5, 2018
Tests `responseDecodable(decoding: Foo.self)` Mar 5, 2018
.gitignore Upgrade xcodeproj to v9; CI all supported confs Aug 26, 2017
.travis.yml Test SwiftPM with Travis (#34) Dec 28, 2018
Cartfile
Cartfile.private
Cartfile.resolved [ci] Run `pod lib lint` for everything we support Oct 10, 2018
Carthage.xcconfig Import from @mxcl/PromiseKit Sep 7, 2016
Info.plist
Package.swift fix Swift Package Manager after update to PromiseKit 6 Dec 27, 2018
Package@swift-4.2.swift Test SwiftPM with Travis (#34) Dec 28, 2018
README.markdown

README.markdown

PromiseKit Alamofire Extensions Build Status

This project adds promises to Alamofire.

This project supports Swift 3.1, 3.2, 4.0 and 4.1.

Usage

Alamofire.request("https://httpbin.org/get", method: .GET)
    .responseJSON().then { json, rsp in
        // 
    }.catch{ error in
        //
    }

Of course, the whole point in promises is composability, so:

func login() -> Promise<User> {
    let q = DispatchQueue.global()
    UIApplication.shared.isNetworkActivityIndicatorVisible = true

    return firstly { in
        Alamofire.request(url, method: .get).responseData()
    }.map(on: q) { data, rsp in
        convertToUser(data)
    }.ensure {
        UIApplication.shared.isNetworkActivityIndicatorVisible = false
    }
}

firstly {
    login()
}.done { user in
    //
}.catch { error in
   UIAlertController(/**/).show() 
}

CocoaPods

# Podfile
pod 'PromiseKit/Alamofire', '~> 6.0'
// `.swift` files
import PromiseKit
import Alamofire
// `.m files`
@import PromiseKit;
@import Alamofire;

Carthage

github "PromiseKit/Alamofire-" ~> 3.0

The extensions are built into their own framework:

// `.swift` files
import PromiseKit
import PMKAlamofire
// `.m files`
@import PromiseKit;
@import PMKAlamofire;

SwiftPM

let package = Package(
    dependencies: [
        .Target(url: "https://github.com/PromiseKit/Alamofire", majorVersion: 3)
    ]
)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.