Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Libraries Usage/RxMoyaExample/Podfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
platform :ios, '8.0'
platform :ios, '9.0'
use_frameworks!

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
end
end
end

target 'RxMoyaExample' do

pod 'Moya/RxSwift'
pod 'Moya-ModelMapper/RxSwift'
pod 'RxSwift', '~> 2.0'
pod 'RxCocoa', '~> 2.0'
pod 'RxOptional', '~> 2.0'
pod 'RxSwift', '~> 3.0.0-beta.2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because now RxSwift is officially 3.0.0, can we try with 3.0.0 versions of RxSwift & RxCocoa? :)

pod 'RxCocoa', '~> 3.0.0-beta.2'

pod 'Moya', '~> 8.0.0-beta.3'
pod 'Moya/RxSwift', '~> 8.0.0-beta.3'
pod 'Moya-ModelMapper/RxSwift', '~> 4.0.0-beta.2'
pod 'RxOptional', '~> 3.1.2'

end
75 changes: 38 additions & 37 deletions Libraries Usage/RxMoyaExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
PODS:
- Alamofire (3.4.1)
- ModelMapper (2.1.0)
- Moya (7.0.0):
- Moya/Core (= 7.0.0)
- Moya-ModelMapper/Core (3.0.0):
- ModelMapper (~> 2.0)
- Moya (~> 7.0)
- Moya-ModelMapper/RxSwift (3.0.0):
- Alamofire (4.0.1)
- ModelMapper (5.0.0)
- Moya (8.0.0-beta.3):
- Moya/Core (= 8.0.0-beta.3)
- Moya-ModelMapper/Core (4.0.0-beta.2):
- ModelMapper (= 5.0.0)
- Moya (= 8.0.0-beta.3)
- Moya-ModelMapper/RxSwift (4.0.0-beta.2):
- Moya-ModelMapper/Core
- Moya/RxSwift (~> 7.0)
- RxSwift (~> 2.3)
- Moya/Core (7.0.0):
- Alamofire (~> 3.0)
- Result (~> 2.0)
- Moya/RxSwift (7.0.0):
- Moya/RxSwift (= 8.0.0-beta.3)
- RxSwift (= 3.0.0-rc.1)
- Moya/Core (8.0.0-beta.3):
- Alamofire (~> 4.0.0)
- Result
- Moya/RxSwift (8.0.0-beta.3):
- Moya/Core
- RxSwift (~> 2.0)
- Result (2.1.3)
- RxCocoa (2.6.0):
- RxSwift (~> 2.5)
- RxOptional (2.0.0):
- RxCocoa (~> 2.0)
- RxSwift (~> 2.0)
- RxSwift (2.6.0)
- RxSwift
- Result (3.0.0)
- RxCocoa (3.0.0-rc.1):
- RxSwift (~> 3.0.0-rc.1)
- RxOptional (3.1.2):
- RxCocoa
- RxSwift
- RxSwift (3.0.0-rc.1)

DEPENDENCIES:
- Moya-ModelMapper/RxSwift
- Moya/RxSwift
- RxCocoa (~> 2.0)
- RxOptional (~> 2.0)
- RxSwift (~> 2.0)
- Moya (~> 8.0.0-beta.3)
- Moya-ModelMapper/RxSwift (~> 4.0.0-beta.2)
- Moya/RxSwift (~> 8.0.0-beta.3)
- RxCocoa (~> 3.0.0-beta.2)
- RxOptional (~> 3.1.2)
- RxSwift (~> 3.0.0-beta.2)

SPEC CHECKSUMS:
Alamofire: 01a82e2f6c0f860ade35534c8dd88be61bdef40c
ModelMapper: e599744bc1e869bdb87b453b7ce16981028b8513
Moya: f004b82418fb8165ee1fc9f86190db4b3611fda9
Moya-ModelMapper: b4ffff5dfd8cdd338f5a586090eae82166df5ac4
Result: 18e1a7597fbcca5923c565b40a25a98afafdee02
RxCocoa: 89ab00d5753502520227940e3a0e0a0413683c6b
RxOptional: b77fb47a0190213cf8a37c7a2b7fda28160b4563
RxSwift: 77f3a0b15324baa7a1c9bfa9f199648a82424e26
Alamofire: 7682d43245de14874acd142ec137b144aa1dd335
ModelMapper: 89ced1f51ec6360e93f6889d08c818d4cad526a3
Moya: f83c7f81eaa28cb0151549dfcf1f3fda4440bb50
Moya-ModelMapper: 2a2e8a1e6c50bf1022c53f31c22325b672caeded
Result: 1b3e431f37cbcd3ad89c6aa9ab0ae55515fae3b6
RxCocoa: e72a074a7f38896ec0382d096df5f58df10115c7
RxOptional: 91e488186acdfe6d15b3fdef296aecf4ba061c03
RxSwift: d7a3819dd71789c473e3cbf1a0c02d58b2692739

PODFILE CHECKSUM: e350aaa99f7dd9beb8b92ec967f4091709cd4af7
PODFILE CHECKSUM: 5a4253dad895e4c65a9ded9dd4aeda2fcee2e5f4

COCOAPODS: 1.0.1
COCOAPODS: 1.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
TargetAttributes = {
14F750C51C6B8289005EED40 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -228,7 +229,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -362,6 +363,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxMoyaExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -377,6 +379,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxMoyaExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
12 changes: 6 additions & 6 deletions Libraries Usage/RxMoyaExample/RxMoyaExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
Expand Down
46 changes: 25 additions & 21 deletions Libraries Usage/RxMoyaExample/RxMoyaExample/GithubEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,51 @@ import Moya

private extension String {
var URLEscapedString: String {
return self.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet())!
return self.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlHostAllowed)!
}
}

enum GitHub {
case UserProfile(username: String)
case Repos(username: String)
case Repo(fullName: String)
case Issues(repositoryFullName: String)
case userProfile(username: String)
case repos(username: String)
case repo(fullName: String)
case issues(repositoryFullName: String)
}

extension GitHub: TargetType {
var baseURL: NSURL { return NSURL(string: "https://api.github.com")! }
public var task: Task {
return .request
}

var baseURL: URL { return URL(string: "https://api.github.com")! }
var path: String {
switch self {
case .Repos(let name):
case .repos(let name):
return "/users/\(name.URLEscapedString)/repos"
case .UserProfile(let name):
case .userProfile(let name):
return "/users/\(name.URLEscapedString)"
case .Repo(let name):
case .repo(let name):
return "/repos/\(name)"
case .Issues(let repositoryName):
case .issues(let repositoryName):
return "/repos/\(repositoryName)/issues"
}
}
var method: Moya.Method {
return .GET
return .get
}
var parameters: [String: AnyObject]? {
var parameters: [String: Any]? {
return nil
}
var sampleData: NSData {
var sampleData: Data {
switch self {
case .Repos(_):
return "{{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}}}".dataUsingEncoding(NSUTF8StringEncoding)!
case .UserProfile(let name):
return "{\"login\": \"\(name)\", \"id\": 100}".dataUsingEncoding(NSUTF8StringEncoding)!
case .Repo(_):
return "{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}".dataUsingEncoding(NSUTF8StringEncoding)!
case .Issues(_):
return "{\"id\": 132942471, \"number\": 405, \"title\": \"Updates example with fix to String extension by changing to Optional\", \"body\": \"Fix it pls.\"}".dataUsingEncoding(NSUTF8StringEncoding)!
case .repos(_):
return "{{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}}}".data(using: String.Encoding.utf8)!
case .userProfile(let name):
return "{\"login\": \"\(name)\", \"id\": 100}".data(using: String.Encoding.utf8)!
case .repo(_):
return "{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}".data(using: String.Encoding.utf8)!
case .issues(_):
return "{\"id\": 132942471, \"number\": 405, \"title\": \"Updates example with fix to String extension by changing to Optional\", \"body\": \"Fix it pls.\"}".data(using: String.Encoding.utf8)!
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class IssueListViewController: UIViewController {

var latestRepositoryName: Observable<String> {
return searchBar
.rx_text
.rx.text
.throttle(0.5, scheduler: MainScheduler.instance)
.distinctUntilChanged()
}
Expand All @@ -63,8 +63,8 @@ class IssueListViewController: UIViewController {
// we have filled up about 3 table view data source methods
issueTrackerModel
.trackIssues()
.bindTo(tableView.rx_itemsWithCellFactory) { (tableView, row, item) in
let cell = tableView.dequeueReusableCellWithIdentifier("issueCell", forIndexPath: NSIndexPath(forRow: row, inSection: 0))
.bindTo(tableView.rx.items) { (tableView, row, item) in
let cell = tableView.dequeueReusableCell(withIdentifier: "issueCell", for: IndexPath(row: row, section: 0))
cell.textLabel?.text = item.title

return cell
Expand All @@ -74,17 +74,17 @@ class IssueListViewController: UIViewController {
// Here we tell table view that if user clicks on a cell,
// and the keyboard is still visible, hide it
tableView
.rx_itemSelected
.subscribeNext { indexPath in
if self.searchBar.isFirstResponder() == true {
.rx.itemSelected
.subscribe { indexPath in
if self.searchBar.isFirstResponder == true {
self.view.endEditing(true)
}
}
.addDisposableTo(disposeBag)
}

func url(route: TargetType) -> String {
return route.baseURL.URLByAppendingPathComponent(route.path).absoluteString
func url(_ route: TargetType) -> String {
return route.baseURL.appendingPathComponent(route.path).absoluteString
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ struct IssueTrackerModel {
.replaceNilWith([])
}

internal func findIssues(repository: Repository) -> Observable<[Issue]?> {
internal func findIssues(_ repository: Repository) -> Observable<[Issue]?> {
return self.provider
.request(GitHub.Issues(repositoryFullName: repository.fullName))
.request(GitHub.issues(repositoryFullName: repository.fullName))
.debug()
.mapArrayOptional(Issue.self)
.mapArrayOptional(type: Issue.self)
}

internal func findRepository(name: String) -> Observable<Repository?> {
internal func findRepository(_ name: String) -> Observable<Repository?> {
return self.provider
.request(GitHub.Repo(fullName: name))
.request(GitHub.repo(fullName: name))
.debug()
.mapObjectOptional(Repository.self)
.mapObjectOptional(type: Repository.self)
}
}
}
18 changes: 15 additions & 3 deletions Libraries Usage/RxSwiftExample/Podfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
platform :ios, '8.0'
platform :ios, '10.0'
use_frameworks!

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
end
end
end


target 'RxSwiftExample' do
use_frameworks!

pod "RxSwift"
pod "RxCocoa"
pod 'RxSwift', '~> 3.0.0-beta.2'
pod 'RxCocoa', '~> 3.0.0-beta.2'
# pod 'RxDataSources', '~> 1.0.0-beta.2'

end

18 changes: 10 additions & 8 deletions Libraries Usage/RxSwiftExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
PODS:
- RxCocoa (2.1.0):
- RxSwift (~> 2.0)
- RxSwift (2.1.0)
- RxCocoa (3.0.0-beta.2):
- RxSwift (~> 3.0.0-beta.2)
- RxSwift (3.0.0-beta.2)

DEPENDENCIES:
- RxCocoa
- RxSwift
- RxCocoa (~> 3.0.0-beta.2)
- RxSwift (~> 3.0.0-beta.2)

SPEC CHECKSUMS:
RxCocoa: 79b5feb8378545336e756a0a33fcf5e95050b71c
RxSwift: 110fb07f81c17c2c3b3254d168363057b1880d18
RxCocoa: 1dd105d8a4e18034ccd7bd6d136445363ce67c8e
RxSwift: 0ea939d7d97cb70657190ffde8dc2a9b455778fc

COCOAPODS: 0.39.0
PODFILE CHECKSUM: 711b5270a9a6ca25724d6401b82265e98651f079

COCOAPODS: 1.0.1
Loading