ReactiveHeimdall is a ReactiveCocoa-based extension to Heimdallr.swift.
Installation is possible via Carthage or CocoaPods, see below for either method:
Carthage is a simple, decentralized dependency manager for Cocoa.
- Add ReactiveHeimdall to your Cartfile:
github "trivago/ReactiveHeimdall" ~> 2.0
-
Run
carthage update
to fetch and build Heimdall and its dependencies.
-
Add ReactiveHeimdall to your Podfile:
pod 'ReactiveHeimdall', :git => 'https://github.com/trivago/ReactiveHeimdall.git', :tag => '2.0'
-
Run
pod install
to fetch and build ReactiveHeimdall and its dependencies.
When requesting an access token the signal completes on success
let signal = heimdall.requestAccessToken("foo", password: "bar")
signal.subscribeCompleted {
// access token has been aquired
}
signal.subscribeError { error in
// access token could not be acquired
}
When authenticating a request the signal sends the authenticated request and completes on success
let signal = heimdall.authenticateRequest(NSURLRequest(URL: NSURL(string: "http://www.trivago.com/foobar")!))
signal.subscribeNext { value in
let request = value as? NSURLRequest // request is the authenticated `NSURLRequest`
}
signal.subscribeError { error in
// request could not be authorized
}