├── .gitignore
├── Changelog.md
├── LICENSE
├── Libraries Usage
├── README.md
├── RxActionExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxActionExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxActionExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxActionExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
├── RxAlamofireExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxAlamofireExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxAlamofireExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxAlamofireExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── RepositoriesViewController.swift
│ │ ├── Repository.swift
│ │ └── RepositoryNetworkModel.swift
├── RxDataSourcesExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxDataSourcesExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxDataSourcesExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxDataSourcesExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── DefaultSection.swift
│ │ ├── Info.plist
│ │ └── ViewController.swift
├── RxMKMapViewExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxMKMapViewExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxMKMapViewExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxMKMapViewExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
├── RxMoyaExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxMoyaExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxMoyaExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxMoyaExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── GithubEndpoint.swift
│ │ ├── Info.plist
│ │ ├── IssueEntity.swift
│ │ ├── IssueListViewController.swift
│ │ ├── IssueTrackerModel.swift
│ │ └── RespositoryEntity.swift
├── RxSwiftExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxSwiftExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── RxSwiftExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── RxSwiftExample
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
└── RxWebKitExample
│ ├── Podfile
│ ├── Podfile.lock
│ ├── RxWebKitExample.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── RxWebKitExample.xcworkspace
│ └── contents.xcworkspacedata
│ └── RxWebKitExample
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
├── README.md
└── Simple Apps
├── ColourfulBall
├── ColourfulBall.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── ColourfulBall.xcworkspace
│ └── contents.xcworkspacedata
├── ColourfulBall
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ └── LaunchScreen.storyboard
│ ├── CircleViewModel.swift
│ ├── Info.plist
│ ├── Main.storyboard
│ └── ViewController.swift
├── Podfile
└── Podfile.lock
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Build generated
2 | build/
3 | DerivedData
4 |
5 | ## Various settings
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata
15 |
16 | ## Other
17 | *.xccheckout
18 | *.moved-aside
19 | *.xcuserstate
20 | *.xcscmblueprint
21 |
22 | ## Obj-C/Swift specific
23 | *.hmap
24 | *.ipa
25 |
26 | # Swift Package Manager
27 | Packages/
28 | .build/
29 |
30 | # CocoaPods
31 | Pods/
32 |
33 | # Carthage
34 | Carthage/Checkouts
35 | Carthage/Build
36 |
37 | # fastlane
38 | fastlane/ipa/
39 | fastlane/reports
40 | fastlane/report.xml
41 | fastlane/screenshots
42 |
--------------------------------------------------------------------------------
/Changelog.md:
--------------------------------------------------------------------------------
1 | # Next
2 | - Added
3 | - RxBluetoothKit
4 | - RxMultipeer
5 | - RxMarbles
6 | - RxSwift by Examples \#4 - Multithreading
7 |
8 | # 0.2
9 | - Added
10 | - RxGesture
11 | - RxSegue
12 | - RxSimpleNoSQL
13 | - RxExt
14 | - Cell+Rx
15 | - RxTwift
16 | - RxAppState
17 | - RxPermission
18 | - Removed
19 | - Calculator from Simple Apps
20 |
21 | # 0.1
22 | - Initial release! 🎉
23 | - Moved and renamed RxViewModelExample to ColourfulBall, since this example didn't really need RxViewModel lib.
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Droids on Roids LLC
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Libraries Usage/README.md:
--------------------------------------------------------------------------------
1 | ## List of examples
2 | - Example of using [RxSwift](https://github.com/ReactiveX/RxSwift) - [RxSwiftExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxSwiftExample). This should be the start.
3 | - Example of using [Action](https://github.com/RxSwiftCommunity/Action) - [RxActionExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxActionExample).
4 | - Example of using [RxAlamofire](https://github.com/RxSwiftCommunity/RxAlamofire/) - [RxAlamofireExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxAlamofireExample).
5 | - Example of using [RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources/) - [RxDataSourcesExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxDataSourcesExample).
6 | - Example of using [Moya](https://github.com/Moya/Moya/) with `RxSwift` - [RxMoyaExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxMoyaExample).
7 | - Example of using [RxWebKit](https://github.com/RxSwiftCommunity/RxWebKit) -
8 | [RxWebKitExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxWebKitExample).
9 | - Example of using [RxMKMapView](https://github.com/RxSwiftCommunity/RxMKMapView) -
10 | [RxMKMapViewExample](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/RxMKMapViewExample).
11 |
12 | ## Author
13 |
14 | Sunshinejr, thesunshinejr@gmail.com, @thesunshinejr
15 |
16 | ## License
17 |
18 | RxSwiftExamples is available under the MIT license. See the LICENSE file for more info.
19 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | use_frameworks!
3 |
4 | target 'RxActionExample' do
5 |
6 | pod 'Action', '~> 2.0.0'
7 |
8 | end
9 |
10 | post_install do |installer|
11 | installer.pods_project.targets.each do |target|
12 | target.build_configurations.each do |config|
13 | if config.name == 'Debug'
14 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
15 | config.build_settings['SWIFT_VERSION'] = '3.0'
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Action (2.0.0):
3 | - RxCocoa (~> 3.0)
4 | - RxSwift (~> 3.0)
5 | - RxCocoa (3.0.1):
6 | - RxSwift (~> 3.0)
7 | - RxSwift (3.0.1)
8 |
9 | DEPENDENCIES:
10 | - Action (~> 2.0.0)
11 |
12 | SPEC CHECKSUMS:
13 | Action: 0bc7f713038917e2d8b7a0cc71278a79c1db06c1
14 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
15 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
16 |
17 | PODFILE CHECKSUM: 4749c0cd4c60677e1d71f8634f2e69d25a34300b
18 |
19 | COCOAPODS: 1.1.1
20 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxActionExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxActionExample/RxActionExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxActionExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 | //
9 | // In this project we have basic regsitration form that enables
10 | // button upon filling in all the fields. If every field has at
11 | // least one character, we acknowledge it as being "good". Of
12 | // course in real world you would like to do some more filtering
13 | // like checking email or password & login length etc. But to modify
14 | // it for your needs there is not much to do other than overrite
15 | // mapping part where we just check the characters' count property.
16 | // This example shows how easy it can be to attach Action to a button
17 | // and remove all the boilerplate code like delegates and such.
18 | //
19 | //
20 |
21 | import Action
22 | import UIKit
23 | import RxCocoa
24 | import RxSwift
25 |
26 | class ViewController: UIViewController {
27 |
28 | @IBOutlet var formFields: [UITextField]!
29 | @IBOutlet weak var registerButton: UIButton!
30 | @IBOutlet weak var stackView: UIStackView!
31 |
32 | var currentTranslation: CGFloat = 0
33 | let disposeBag = DisposeBag()
34 |
35 | override func viewDidLoad() {
36 | super.viewDidLoad()
37 | setup()
38 | }
39 |
40 | func setup() {
41 | setupRX()
42 | setupUI()
43 | }
44 |
45 | func setupRX() {
46 | let validUsernameCollection = formFields // take array of inputs
47 | .map { input in
48 | input.rx.text
49 | .filter { $0 != nil }
50 | .map { $0! }
51 | .map { $0.characters.count > 0 } // map them into array of Observable
52 | } // this allows us to use combineLatest, which fires up whenever any of the observables emits a signal
53 |
54 | let validUsername = Observable.combineLatest(validUsernameCollection) { filters in
55 | return filters.filter { $0 }.count == filters.count // if every input has length > 0, emit true
56 | }
57 |
58 | let action = Action(enabledIf: validUsername) { input in
59 | let alert = UIAlertController(title: "Wooo!", message: "Registration completed!", preferredStyle: .alert)
60 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
61 | self.present(alert, animated: true, completion: nil)
62 | return .empty()
63 | }
64 |
65 | registerButton.rx.action = action
66 | }
67 |
68 | func setupUI() {
69 | NotificationCenter.default.addObserver(
70 | self,
71 | selector: #selector(keyboardWillShow(_:)),
72 | name: NSNotification.Name.UIKeyboardWillShow,
73 | object: nil)
74 |
75 | NotificationCenter.default.addObserver(
76 | self,
77 | selector: #selector(keyboardWillHide(_:)),
78 | name: NSNotification.Name.UIKeyboardWillHide,
79 | object: nil)
80 | }
81 |
82 | deinit {
83 | NotificationCenter.default.removeObserver(self)
84 | }
85 |
86 | func keyboardWillShow(_ notification: Notification) {
87 | guard let keyboardFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else { return }
88 | let margin: CGFloat = 10.0
89 | var responderY: CGFloat!
90 | formFields.forEach { field in
91 | if field.isFirstResponder {
92 | responderY = field.frame.maxY + stackView.frame.minY
93 | return
94 | }
95 | }
96 | currentTranslation = currentTranslation + responderY - keyboardFrame.minY + margin
97 | if currentTranslation != 0 {
98 | UIView.animate(withDuration: 0.3, animations: {
99 | self.stackView.transform = CGAffineTransform(translationX: 0.0, y: (-1)*self.currentTranslation)
100 | })
101 | }
102 | }
103 |
104 | func keyboardWillHide(_ notification: Notification) {
105 | UIView.animate(withDuration: 0.3, animations: {
106 | self.currentTranslation = 0.0
107 | self.stackView.transform = CGAffineTransform(translationX: 0.0, y: 0.0)
108 | })
109 | }
110 |
111 | override func touchesBegan(_ touches: Set, with event: UIEvent?) {
112 | super.touchesBegan(touches, with: event)
113 | view.endEditing(true)
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 | use_frameworks!
3 |
4 | target 'RxAlamofireExample' do
5 |
6 | pod 'RxAlamofire/RxCocoa', '~> 3.0.0'
7 | pod 'ObjectMapper', '~> 2.2.0'
8 |
9 | end
10 |
11 | post_install do |installer|
12 | installer.pods_project.targets.each do |target|
13 | target.build_configurations.each do |config|
14 | if config.name == 'Debug'
15 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
16 | config.build_settings['SWIFT_VERSION'] = '3.0'
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Alamofire (4.0.1)
3 | - ObjectMapper (2.2.1)
4 | - RxAlamofire/Core (3.0.0):
5 | - Alamofire (~> 4.0)
6 | - RxSwift (~> 3.0)
7 | - RxAlamofire/RxCocoa (3.0.0):
8 | - RxAlamofire/Core
9 | - RxCocoa (~> 3.0)
10 | - RxCocoa (3.0.1):
11 | - RxSwift (~> 3.0)
12 | - RxSwift (3.0.1)
13 |
14 | DEPENDENCIES:
15 | - ObjectMapper (~> 2.2.0)
16 | - RxAlamofire/RxCocoa (~> 3.0.0)
17 |
18 | SPEC CHECKSUMS:
19 | Alamofire: 7682d43245de14874acd142ec137b144aa1dd335
20 | ObjectMapper: 41e43e1a89f8060ef5ea5d04ba852e269a621d68
21 | RxAlamofire: 0b1fa48f545fffe7f7a28af2086bcaa3b5946cc9
22 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
23 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
24 |
25 | PODFILE CHECKSUM: fd159d27023d0da367a6158bc273a6c42b5a9205
26 |
27 | COCOAPODS: 1.1.1
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxAlamofireExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/RepositoriesViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RepositoriesViewController.swift
3 | // RxAlamofireExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 | //
9 | // In this app we connect few libraries to make repository search
10 | // through GitHub API. Lets split it for few steps.
11 | // First step would be to setup RxSwift so we can observe text
12 | // from UISearchBar and get the updates. When we get the update,
13 | // we have to make sure we are not spamming API. So we will make
14 | // use of throttle(_:scheduler) and distinctUntilChanged(). Also
15 | // remember to use it in the same order as in the example (to make
16 | // sure you get updates from the main thread always, because
17 | // otherwise distinct might not work correctly). Then the next step
18 | // would be to get the actual query from UISearchBar and now, that
19 | // we know that we will not spam API, we can make a Alamofire
20 | // request. To do it, we will also use RxSwift, now with the
21 | // RxAlamofire wrapper. It makes using Alamofire nice and clean,
22 | // as you can see in the code. We will make a requst to GitHub
23 | // API and fetch the request for given username. To parse json
24 | // array into Repository objects we will use ObjectMapper here.
25 | // And thats it! Not that hard, right? Oh, and also be careful
26 | // about Schedulers. :wink:
27 | //
28 |
29 | import UIKit
30 | import ObjectMapper
31 | import RxAlamofire
32 | import RxCocoa
33 | import RxSwift
34 |
35 | class RepositoriesViewController: UIViewController {
36 |
37 | @IBOutlet weak var tableViewBottomConstraint: NSLayoutConstraint!
38 | @IBOutlet weak var tableView: UITableView!
39 | @IBOutlet weak var searchBar: UISearchBar!
40 | let disposeBag = DisposeBag()
41 | var repositoryNetworkModel: RepositoryNetworkModel!
42 |
43 | var rx_searchBarText: Observable {
44 | return searchBar.rx.text
45 | .filter { $0 != nil }
46 | .map { $0! }
47 | .filter { $0.characters.count > 0 }
48 | .debounce(0.5, scheduler: MainScheduler.instance)
49 | .distinctUntilChanged()
50 | }
51 |
52 | override func viewDidLoad() {
53 | super.viewDidLoad()
54 | setupRx()
55 | }
56 |
57 | func setupRx() {
58 | repositoryNetworkModel = RepositoryNetworkModel(withNameObservable: rx_searchBarText)
59 |
60 | repositoryNetworkModel
61 | .rx_repositories
62 | .drive(tableView.rx.items) { (tv, i, repository) in
63 | let cell = tv.dequeueReusableCell(withIdentifier: "repositoryCell", for: IndexPath(row: i, section: 0))
64 | cell.textLabel?.text = repository.name
65 |
66 | return cell
67 | }
68 | .addDisposableTo(disposeBag)
69 |
70 | repositoryNetworkModel
71 | .rx_repositories
72 | .drive(onNext: { repositories in
73 | if repositories.count == 0 {
74 | let alert = UIAlertController(title: ":(", message: "No repositories for this user.", preferredStyle: .alert)
75 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
76 | if self.navigationController?.visibleViewController is UIAlertController != true {
77 | self.present(alert, animated: true, completion: nil)
78 | }
79 | }
80 | })
81 | .addDisposableTo(disposeBag)
82 | }
83 |
84 | func setupUI() {
85 | let tap = UITapGestureRecognizer(target: self, action: #selector(tableTapped(_:)))
86 | tableView.addGestureRecognizer(tap)
87 | NotificationCenter.default.addObserver(
88 | self,
89 | selector: #selector(keyboardWillShow(_:)),
90 | name: NSNotification.Name.UIKeyboardWillShow,
91 | object: nil)
92 |
93 | NotificationCenter.default.addObserver(
94 | self,
95 | selector: #selector(keyboardWillHide(_:)),
96 | name: NSNotification.Name.UIKeyboardWillHide,
97 | object: nil)
98 | }
99 |
100 | deinit {
101 | NotificationCenter.default.removeObserver(self)
102 | }
103 |
104 | func keyboardWillShow(_ notification: Notification) {
105 | guard let keyboardFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else { return }
106 | tableViewBottomConstraint.constant = keyboardFrame.height
107 | UIView.animate(withDuration: 0.3, animations: {
108 | self.view.updateConstraints()
109 | })
110 | }
111 |
112 | func keyboardWillHide(_ notification: Notification) {
113 | tableViewBottomConstraint.constant = 0.0
114 | UIView.animate(withDuration: 0.3, animations: {
115 | self.view.updateConstraints()
116 | })
117 | }
118 |
119 | func tableTapped(_ recognizer: UITapGestureRecognizer) {
120 | let location = recognizer.location(in: tableView)
121 | let path = tableView.indexPathForRow(at: location)
122 | if searchBar.isFirstResponder {
123 | searchBar.resignFirstResponder()
124 | } else if let path = path {
125 | tableView.selectRow(at: path, animated: true, scrollPosition: .middle)
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/Repository.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Repository.swift
3 | // RxAlamofireExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import ObjectMapper
10 |
11 | class Repository: Mappable {
12 | var identifier: Int!
13 | var language: String!
14 | var url: String!
15 | var name: String!
16 |
17 | required init?(map: Map) { }
18 |
19 | func mapping(map: Map) {
20 | identifier <- map["id"]
21 | language <- map["language"]
22 | url <- map["url"]
23 | name <- map["name"]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Libraries Usage/RxAlamofireExample/RxAlamofireExample/RepositoryNetworkModel.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RepositoryNetworkModel.swift
3 | // RxAlamofireExample
4 | //
5 | // Created by Lukasz Mroz on 25.04.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import ObjectMapper
10 | import RxAlamofire
11 | import RxCocoa
12 | import RxSwift
13 |
14 | struct RepositoryNetworkModel {
15 |
16 | lazy var rx_repositories: Driver<[Repository]> = self.fetchRepositories()
17 | fileprivate var repositoryName: Observable
18 |
19 | init(withNameObservable nameObservable: Observable) {
20 | self.repositoryName = nameObservable
21 | }
22 |
23 | fileprivate func fetchRepositories() -> Driver<[Repository]> {
24 | return repositoryName
25 | .subscribeOn(MainScheduler.instance) // Make sure we are on MainScheduler
26 | .do(onNext: { response in
27 | UIApplication.shared.isNetworkActivityIndicatorVisible = true
28 | })
29 | .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
30 | .flatMapLatest { text in // .background thread, network request
31 | return RxAlamofire
32 | .requestJSON(.get, "https://api.github.com/users/\(text)/repos")
33 | .debug()
34 | .catchError { error in
35 | return Observable.never()
36 | }
37 | }
38 | .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
39 | .map { (response, json) -> [Repository] in // again back to .background, map objects
40 | if let repos = Mapper().mapArray(JSONObject: json) {
41 | return repos
42 | } else {
43 | return []
44 | }
45 | }
46 | .observeOn(MainScheduler.instance) // switch to MainScheduler, UI updates
47 | .do(onNext: { response in
48 | UIApplication.shared.isNetworkActivityIndicatorVisible = false
49 | })
50 | .asDriver(onErrorJustReturn: []) // This also makes sure that we are on MainScheduler
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | use_frameworks!
3 |
4 | target 'RxDataSourcesExample' do
5 |
6 | pod "RxDataSources", "~> 1.0.0"
7 | pod "NSObject+Rx", "~> 2.0.0"
8 |
9 | end
10 |
11 | post_install do |installer|
12 | installer.pods_project.targets.each do |target|
13 | target.build_configurations.each do |config|
14 | if config.name == 'Debug'
15 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
16 | config.build_settings['SWIFT_VERSION'] = '3.0'
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - NSObject+Rx (2.0.0):
3 | - RxSwift
4 | - RxCocoa (3.0.1):
5 | - RxSwift (~> 3.0)
6 | - RxDataSources (1.0.0):
7 | - RxCocoa (~> 3.0)
8 | - RxSwift (~> 3.0)
9 | - RxSwift (3.0.1)
10 |
11 | DEPENDENCIES:
12 | - NSObject+Rx (~> 2.0.0)
13 | - RxDataSources (~> 1.0.0)
14 |
15 | SPEC CHECKSUMS:
16 | NSObject+Rx: 2a9cd801d9c847e6d2486cbad8d7701b67834e70
17 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
18 | RxDataSources: 824693e84d00781d0a5e5cedc1ff95ce9250aacd
19 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
20 |
21 | PODFILE CHECKSUM: b3490764254da45dabe95d550e5ded812682583d
22 |
23 | COCOAPODS: 1.1.1
24 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxDataSourcesExample
4 | //
5 | // Created by Lukasz Mroz on 08.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/DefaultSection.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DefaultSection.swift
3 | // RxDataSourcesExample
4 | //
5 | // Created by Lukasz Mroz on 08.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxDataSources
11 |
12 | public struct DefaultSection: AnimatableSectionModelType {
13 |
14 | public typealias Item = DefaultItem
15 | public typealias Identity = String
16 |
17 | var header: String
18 | var storedItems: [Item] {
19 | didSet {
20 | updated = Date()
21 | }
22 | }
23 | var updated: Date
24 |
25 | init(header: String, items: [Item], updated: Date) {
26 | self.header = header
27 | self.storedItems = items
28 | self.updated = updated
29 | }
30 |
31 | public init(original: DefaultSection, items: [Item]) {
32 | self = original
33 | self.storedItems = items
34 | }
35 |
36 | public var identity: Identity {
37 | return header
38 | }
39 |
40 | public var items: [Item] {
41 | return storedItems
42 | }
43 | }
44 |
45 | public struct DefaultItem {
46 | let title: String
47 | let dateChanged: Date
48 | }
49 |
50 | extension DefaultItem: IdentifiableType, Equatable {
51 | public typealias Identity = String
52 |
53 | public var identity: Identity {
54 | return title
55 | }
56 | }
57 |
58 | public func == (lhs: DefaultItem, rhs: DefaultItem) -> Bool {
59 | return lhs.title == rhs.title && (lhs.dateChanged == rhs.dateChanged)
60 | }
61 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxDataSourcesExample/RxDataSourcesExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxDataSourcesExample
4 | //
5 | // Created by Lukasz Mroz on 08.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 | //
9 | // This is basically the copy of RxSwiftExample, but using RxDataSources and NSObject-Rx,
10 | // from the awesome RxSwiftCommunity. The first module, RxDataSources, allows to easily
11 | // use blocks and bind them to table views instead of using large delegate methods. The
12 | // second one, NSObject-Rx, is just a wrapper that you don't have to everytime write
13 | // DisposableBags, Rx will take care of it for you!
14 | //
15 |
16 | import UIKit
17 | import RxSwift
18 | import RxCocoa
19 | import RxDataSources
20 | import NSObject_Rx
21 |
22 | class ViewController: UIViewController {
23 |
24 | @IBOutlet weak var tableView: UITableView!
25 | @IBOutlet weak var searchBar: UISearchBar!
26 |
27 | let dataSource = RxTableViewSectionedReloadDataSource()
28 | var shownCitiesSection: DefaultSection!
29 | var allCities = [String]()
30 | var sections = PublishSubject<[DefaultSection]>()
31 |
32 | override func viewDidLoad() {
33 | super.viewDidLoad()
34 | setup()
35 | }
36 |
37 | func setup() {
38 | allCities = ["New York", "London", "Oslo", "Warsaw", "Berlin", "Praga"]
39 | shownCitiesSection = DefaultSection(header: "Cities", items: allCities.toItems(), updated: Date())
40 | sections.onNext([shownCitiesSection])
41 | dataSource.configureCell = { (_, tableView, indexPath, index) in
42 | let cell = tableView.dequeueReusableCell(withIdentifier: "cityPrototypeCell", for: indexPath)
43 | cell.textLabel?.text = self.shownCitiesSection.items[indexPath.row].title
44 | return cell
45 | }
46 |
47 | sections
48 | .asObservable()
49 | .bindTo(tableView.rx.items(dataSource: dataSource))
50 | .addDisposableTo(rx_disposeBag) // Instead of creating the bag again and again, use the extension NSObject_rx
51 |
52 | searchBar
53 | .rx.text
54 | .filter { $0 != nil }
55 | .map { $0! }
56 | .debounce(0.5, scheduler: MainScheduler.instance)
57 | .distinctUntilChanged()
58 | .subscribe(onNext: { [unowned self] query in
59 | let items: [String]
60 | if query.characters.count > 0 {
61 | items = self.allCities.filter { $0.hasPrefix(query) }
62 | } else {
63 | items = self.allCities
64 | }
65 | self.shownCitiesSection = DefaultSection(
66 | original: self.shownCitiesSection,
67 | items: items.toItems()
68 | )
69 |
70 | self.sections.onNext([self.shownCitiesSection])
71 | })
72 | .addDisposableTo(rx_disposeBag)
73 | }
74 |
75 | }
76 |
77 | extension Collection where Self.Iterator.Element == String {
78 | func toItems() -> [DefaultItem] {
79 | return self.map { DefaultItem(title: $0, dateChanged: Date()) }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | platform :ios, '8.0'
3 | # Uncomment this line if you're using Swift
4 | use_frameworks!
5 |
6 | target 'RxMKMapViewExample' do
7 |
8 | pod 'RxMKMapView'
9 |
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - RxCocoa (2.2.0):
3 | - RxSwift (~> 2.2)
4 | - RxMKMapView (2.0.1):
5 | - RxCocoa (~> 2.2)
6 | - RxSwift (~> 2.2)
7 | - RxSwift (2.2.0)
8 |
9 | DEPENDENCIES:
10 | - RxMKMapView
11 |
12 | SPEC CHECKSUMS:
13 | RxCocoa: 42efb7a7145a8d1d5878e94ce48a580d29e0c796
14 | RxMKMapView: 5477f2facbb010a5e4a4b1b91d2d39635032058c
15 | RxSwift: b8a749f2204c6c7a5c29b306a9c3bc11d5b87c5b
16 |
17 | COCOAPODS: 0.39.0
18 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 14B272871C7633D800606624 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B272861C7633D800606624 /* AppDelegate.swift */; };
11 | 14B272891C7633D800606624 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B272881C7633D800606624 /* ViewController.swift */; };
12 | 14B2728C1C7633D800606624 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14B2728A1C7633D800606624 /* Main.storyboard */; };
13 | 14B2728E1C7633D800606624 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14B2728D1C7633D800606624 /* Assets.xcassets */; };
14 | 14B272911C7633D800606624 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14B2728F1C7633D800606624 /* LaunchScreen.storyboard */; };
15 | 584E109CAB810819604FB693 /* Pods_RxMKMapViewExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B514238612B89E117C5B80F2 /* Pods_RxMKMapViewExample.framework */; };
16 | /* End PBXBuildFile section */
17 |
18 | /* Begin PBXFileReference section */
19 | 14B272831C7633D800606624 /* RxMKMapViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxMKMapViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
20 | 14B272861C7633D800606624 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
21 | 14B272881C7633D800606624 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
22 | 14B2728B1C7633D800606624 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
23 | 14B2728D1C7633D800606624 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
24 | 14B272901C7633D800606624 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
25 | 14B272921C7633D800606624 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
26 | 4A31778D7E7F0FD1EFBC2695 /* Pods-RxMKMapViewExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxMKMapViewExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxMKMapViewExample/Pods-RxMKMapViewExample.release.xcconfig"; sourceTree = ""; };
27 | B514238612B89E117C5B80F2 /* Pods_RxMKMapViewExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RxMKMapViewExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
28 | DEC3F3B5C857441A2DF9DD70 /* Pods-RxMKMapViewExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxMKMapViewExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxMKMapViewExample/Pods-RxMKMapViewExample.debug.xcconfig"; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | 14B272801C7633D800606624 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | 584E109CAB810819604FB693 /* Pods_RxMKMapViewExample.framework in Frameworks */,
37 | );
38 | runOnlyForDeploymentPostprocessing = 0;
39 | };
40 | /* End PBXFrameworksBuildPhase section */
41 |
42 | /* Begin PBXGroup section */
43 | 14B2727A1C7633D800606624 = {
44 | isa = PBXGroup;
45 | children = (
46 | 14B272851C7633D800606624 /* RxMKMapViewExample */,
47 | 14B272841C7633D800606624 /* Products */,
48 | 3D6F160BDC1089B9E691C5B7 /* Pods */,
49 | 9D792903B23787E95C8A2B09 /* Frameworks */,
50 | );
51 | sourceTree = "";
52 | };
53 | 14B272841C7633D800606624 /* Products */ = {
54 | isa = PBXGroup;
55 | children = (
56 | 14B272831C7633D800606624 /* RxMKMapViewExample.app */,
57 | );
58 | name = Products;
59 | sourceTree = "";
60 | };
61 | 14B272851C7633D800606624 /* RxMKMapViewExample */ = {
62 | isa = PBXGroup;
63 | children = (
64 | 14B272861C7633D800606624 /* AppDelegate.swift */,
65 | 14B272881C7633D800606624 /* ViewController.swift */,
66 | 14B2728A1C7633D800606624 /* Main.storyboard */,
67 | 14B2728D1C7633D800606624 /* Assets.xcassets */,
68 | 14B2728F1C7633D800606624 /* LaunchScreen.storyboard */,
69 | 14B272921C7633D800606624 /* Info.plist */,
70 | );
71 | path = RxMKMapViewExample;
72 | sourceTree = "";
73 | };
74 | 3D6F160BDC1089B9E691C5B7 /* Pods */ = {
75 | isa = PBXGroup;
76 | children = (
77 | DEC3F3B5C857441A2DF9DD70 /* Pods-RxMKMapViewExample.debug.xcconfig */,
78 | 4A31778D7E7F0FD1EFBC2695 /* Pods-RxMKMapViewExample.release.xcconfig */,
79 | );
80 | name = Pods;
81 | sourceTree = "";
82 | };
83 | 9D792903B23787E95C8A2B09 /* Frameworks */ = {
84 | isa = PBXGroup;
85 | children = (
86 | B514238612B89E117C5B80F2 /* Pods_RxMKMapViewExample.framework */,
87 | );
88 | name = Frameworks;
89 | sourceTree = "";
90 | };
91 | /* End PBXGroup section */
92 |
93 | /* Begin PBXNativeTarget section */
94 | 14B272821C7633D800606624 /* RxMKMapViewExample */ = {
95 | isa = PBXNativeTarget;
96 | buildConfigurationList = 14B272951C7633D800606624 /* Build configuration list for PBXNativeTarget "RxMKMapViewExample" */;
97 | buildPhases = (
98 | 8E8EB8F5018286E4B2A7E7FF /* Check Pods Manifest.lock */,
99 | 14B2727F1C7633D800606624 /* Sources */,
100 | 14B272801C7633D800606624 /* Frameworks */,
101 | 14B272811C7633D800606624 /* Resources */,
102 | 96C3BB5699275A7E47A30FCD /* Embed Pods Frameworks */,
103 | 73ED784CAAA9673B80217BB3 /* Copy Pods Resources */,
104 | );
105 | buildRules = (
106 | );
107 | dependencies = (
108 | );
109 | name = RxMKMapViewExample;
110 | productName = RxMKMapViewExample;
111 | productReference = 14B272831C7633D800606624 /* RxMKMapViewExample.app */;
112 | productType = "com.apple.product-type.application";
113 | };
114 | /* End PBXNativeTarget section */
115 |
116 | /* Begin PBXProject section */
117 | 14B2727B1C7633D800606624 /* Project object */ = {
118 | isa = PBXProject;
119 | attributes = {
120 | LastSwiftUpdateCheck = 0720;
121 | LastUpgradeCheck = 0720;
122 | ORGANIZATIONNAME = "Droids on Roids";
123 | TargetAttributes = {
124 | 14B272821C7633D800606624 = {
125 | CreatedOnToolsVersion = 7.2.1;
126 | };
127 | };
128 | };
129 | buildConfigurationList = 14B2727E1C7633D800606624 /* Build configuration list for PBXProject "RxMKMapViewExample" */;
130 | compatibilityVersion = "Xcode 3.2";
131 | developmentRegion = English;
132 | hasScannedForEncodings = 0;
133 | knownRegions = (
134 | en,
135 | Base,
136 | );
137 | mainGroup = 14B2727A1C7633D800606624;
138 | productRefGroup = 14B272841C7633D800606624 /* Products */;
139 | projectDirPath = "";
140 | projectRoot = "";
141 | targets = (
142 | 14B272821C7633D800606624 /* RxMKMapViewExample */,
143 | );
144 | };
145 | /* End PBXProject section */
146 |
147 | /* Begin PBXResourcesBuildPhase section */
148 | 14B272811C7633D800606624 /* Resources */ = {
149 | isa = PBXResourcesBuildPhase;
150 | buildActionMask = 2147483647;
151 | files = (
152 | 14B272911C7633D800606624 /* LaunchScreen.storyboard in Resources */,
153 | 14B2728E1C7633D800606624 /* Assets.xcassets in Resources */,
154 | 14B2728C1C7633D800606624 /* Main.storyboard in Resources */,
155 | );
156 | runOnlyForDeploymentPostprocessing = 0;
157 | };
158 | /* End PBXResourcesBuildPhase section */
159 |
160 | /* Begin PBXShellScriptBuildPhase section */
161 | 73ED784CAAA9673B80217BB3 /* Copy Pods Resources */ = {
162 | isa = PBXShellScriptBuildPhase;
163 | buildActionMask = 2147483647;
164 | files = (
165 | );
166 | inputPaths = (
167 | );
168 | name = "Copy Pods Resources";
169 | outputPaths = (
170 | );
171 | runOnlyForDeploymentPostprocessing = 0;
172 | shellPath = /bin/sh;
173 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxMKMapViewExample/Pods-RxMKMapViewExample-resources.sh\"\n";
174 | showEnvVarsInLog = 0;
175 | };
176 | 8E8EB8F5018286E4B2A7E7FF /* Check Pods Manifest.lock */ = {
177 | isa = PBXShellScriptBuildPhase;
178 | buildActionMask = 2147483647;
179 | files = (
180 | );
181 | inputPaths = (
182 | );
183 | name = "Check Pods Manifest.lock";
184 | outputPaths = (
185 | );
186 | runOnlyForDeploymentPostprocessing = 0;
187 | shellPath = /bin/sh;
188 | 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";
189 | showEnvVarsInLog = 0;
190 | };
191 | 96C3BB5699275A7E47A30FCD /* Embed Pods Frameworks */ = {
192 | isa = PBXShellScriptBuildPhase;
193 | buildActionMask = 2147483647;
194 | files = (
195 | );
196 | inputPaths = (
197 | );
198 | name = "Embed Pods Frameworks";
199 | outputPaths = (
200 | );
201 | runOnlyForDeploymentPostprocessing = 0;
202 | shellPath = /bin/sh;
203 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxMKMapViewExample/Pods-RxMKMapViewExample-frameworks.sh\"\n";
204 | showEnvVarsInLog = 0;
205 | };
206 | /* End PBXShellScriptBuildPhase section */
207 |
208 | /* Begin PBXSourcesBuildPhase section */
209 | 14B2727F1C7633D800606624 /* Sources */ = {
210 | isa = PBXSourcesBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | 14B272891C7633D800606624 /* ViewController.swift in Sources */,
214 | 14B272871C7633D800606624 /* AppDelegate.swift in Sources */,
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | };
218 | /* End PBXSourcesBuildPhase section */
219 |
220 | /* Begin PBXVariantGroup section */
221 | 14B2728A1C7633D800606624 /* Main.storyboard */ = {
222 | isa = PBXVariantGroup;
223 | children = (
224 | 14B2728B1C7633D800606624 /* Base */,
225 | );
226 | name = Main.storyboard;
227 | sourceTree = "";
228 | };
229 | 14B2728F1C7633D800606624 /* LaunchScreen.storyboard */ = {
230 | isa = PBXVariantGroup;
231 | children = (
232 | 14B272901C7633D800606624 /* Base */,
233 | );
234 | name = LaunchScreen.storyboard;
235 | sourceTree = "";
236 | };
237 | /* End PBXVariantGroup section */
238 |
239 | /* Begin XCBuildConfiguration section */
240 | 14B272931C7633D800606624 /* Debug */ = {
241 | isa = XCBuildConfiguration;
242 | buildSettings = {
243 | ALWAYS_SEARCH_USER_PATHS = NO;
244 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
245 | CLANG_CXX_LIBRARY = "libc++";
246 | CLANG_ENABLE_MODULES = YES;
247 | CLANG_ENABLE_OBJC_ARC = YES;
248 | CLANG_WARN_BOOL_CONVERSION = YES;
249 | CLANG_WARN_CONSTANT_CONVERSION = YES;
250 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
251 | CLANG_WARN_EMPTY_BODY = YES;
252 | CLANG_WARN_ENUM_CONVERSION = YES;
253 | CLANG_WARN_INT_CONVERSION = YES;
254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
255 | CLANG_WARN_UNREACHABLE_CODE = YES;
256 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
257 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
258 | COPY_PHASE_STRIP = NO;
259 | DEBUG_INFORMATION_FORMAT = dwarf;
260 | ENABLE_STRICT_OBJC_MSGSEND = YES;
261 | ENABLE_TESTABILITY = YES;
262 | GCC_C_LANGUAGE_STANDARD = gnu99;
263 | GCC_DYNAMIC_NO_PIC = NO;
264 | GCC_NO_COMMON_BLOCKS = YES;
265 | GCC_OPTIMIZATION_LEVEL = 0;
266 | GCC_PREPROCESSOR_DEFINITIONS = (
267 | "DEBUG=1",
268 | "$(inherited)",
269 | );
270 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
271 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
272 | GCC_WARN_UNDECLARED_SELECTOR = YES;
273 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
274 | GCC_WARN_UNUSED_FUNCTION = YES;
275 | GCC_WARN_UNUSED_VARIABLE = YES;
276 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
277 | MTL_ENABLE_DEBUG_INFO = YES;
278 | ONLY_ACTIVE_ARCH = YES;
279 | SDKROOT = iphoneos;
280 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
281 | };
282 | name = Debug;
283 | };
284 | 14B272941C7633D800606624 /* Release */ = {
285 | isa = XCBuildConfiguration;
286 | buildSettings = {
287 | ALWAYS_SEARCH_USER_PATHS = NO;
288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
289 | CLANG_CXX_LIBRARY = "libc++";
290 | CLANG_ENABLE_MODULES = YES;
291 | CLANG_ENABLE_OBJC_ARC = YES;
292 | CLANG_WARN_BOOL_CONVERSION = YES;
293 | CLANG_WARN_CONSTANT_CONVERSION = YES;
294 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
295 | CLANG_WARN_EMPTY_BODY = YES;
296 | CLANG_WARN_ENUM_CONVERSION = YES;
297 | CLANG_WARN_INT_CONVERSION = YES;
298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
299 | CLANG_WARN_UNREACHABLE_CODE = YES;
300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
302 | COPY_PHASE_STRIP = NO;
303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
304 | ENABLE_NS_ASSERTIONS = NO;
305 | ENABLE_STRICT_OBJC_MSGSEND = YES;
306 | GCC_C_LANGUAGE_STANDARD = gnu99;
307 | GCC_NO_COMMON_BLOCKS = YES;
308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
310 | GCC_WARN_UNDECLARED_SELECTOR = YES;
311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
312 | GCC_WARN_UNUSED_FUNCTION = YES;
313 | GCC_WARN_UNUSED_VARIABLE = YES;
314 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
315 | MTL_ENABLE_DEBUG_INFO = NO;
316 | SDKROOT = iphoneos;
317 | VALIDATE_PRODUCT = YES;
318 | };
319 | name = Release;
320 | };
321 | 14B272961C7633D800606624 /* Debug */ = {
322 | isa = XCBuildConfiguration;
323 | baseConfigurationReference = DEC3F3B5C857441A2DF9DD70 /* Pods-RxMKMapViewExample.debug.xcconfig */;
324 | buildSettings = {
325 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
326 | INFOPLIST_FILE = RxMKMapViewExample/Info.plist;
327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
328 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxMKMapViewExample;
329 | PRODUCT_NAME = "$(TARGET_NAME)";
330 | };
331 | name = Debug;
332 | };
333 | 14B272971C7633D800606624 /* Release */ = {
334 | isa = XCBuildConfiguration;
335 | baseConfigurationReference = 4A31778D7E7F0FD1EFBC2695 /* Pods-RxMKMapViewExample.release.xcconfig */;
336 | buildSettings = {
337 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
338 | INFOPLIST_FILE = RxMKMapViewExample/Info.plist;
339 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
340 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxMKMapViewExample;
341 | PRODUCT_NAME = "$(TARGET_NAME)";
342 | };
343 | name = Release;
344 | };
345 | /* End XCBuildConfiguration section */
346 |
347 | /* Begin XCConfigurationList section */
348 | 14B2727E1C7633D800606624 /* Build configuration list for PBXProject "RxMKMapViewExample" */ = {
349 | isa = XCConfigurationList;
350 | buildConfigurations = (
351 | 14B272931C7633D800606624 /* Debug */,
352 | 14B272941C7633D800606624 /* Release */,
353 | );
354 | defaultConfigurationIsVisible = 0;
355 | defaultConfigurationName = Release;
356 | };
357 | 14B272951C7633D800606624 /* Build configuration list for PBXNativeTarget "RxMKMapViewExample" */ = {
358 | isa = XCConfigurationList;
359 | buildConfigurations = (
360 | 14B272961C7633D800606624 /* Debug */,
361 | 14B272971C7633D800606624 /* Release */,
362 | );
363 | defaultConfigurationIsVisible = 0;
364 | defaultConfigurationName = Release;
365 | };
366 | /* End XCConfigurationList section */
367 | };
368 | rootObject = 14B2727B1C7633D800606624 /* Project object */;
369 | }
370 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxMKMapViewExample
4 | //
5 | // Created by Lukasz Mroz on 18.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMKMapViewExample/RxMKMapViewExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxMKMapViewExample
4 | //
5 | // Created by Lukasz Mroz on 18.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import MapKit
10 | import RxSwift
11 | import RxCocoa
12 | import RxMKMapView
13 | import UIKit
14 |
15 | class ViewController: UIViewController {
16 |
17 | @IBOutlet weak var mapView: MKMapView!
18 |
19 | let disposeBag = DisposeBag()
20 |
21 | override func viewDidLoad() {
22 | super.viewDidLoad()
23 | setupRx()
24 | }
25 |
26 | func setupRx() {
27 | mapView
28 | .rx_willStartLoadingMap
29 | .subscribeNext {
30 | print("Will start loading map")
31 | }
32 | .addDisposableTo(disposeBag)
33 | mapView
34 | .rx_didFinishLoadingMap
35 | .subscribeNext {
36 | print("Finished loading map")
37 | }
38 | .addDisposableTo(disposeBag)
39 | mapView
40 | .rx_willStartRenderingMap
41 | .subscribeNext {
42 | print("Will start rendering map")
43 | }
44 | .addDisposableTo(disposeBag)
45 | mapView
46 | .rx_didFinishRenderingMap
47 | .subscribeNext { fullyRendered in
48 | print("Finished rendering map? Is it fully rendered tho? Of course \(fullyRendered)!")
49 | }
50 | .addDisposableTo(disposeBag)
51 | }
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | use_frameworks!
3 |
4 | target 'RxMoyaExample' do
5 |
6 | pod 'RxCocoa', '~> 3.0.0'
7 | pod 'Moya-ModelMapper/RxSwift', '~> 4.1.0'
8 | pod 'RxOptional'
9 |
10 | end
11 |
12 | post_install do |installer|
13 | installer.pods_project.targets.each do |target|
14 | target.build_configurations.each do |config|
15 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
16 | config.build_settings['SWIFT_VERSION'] = '3.0'
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Alamofire (4.2.0)
3 | - ModelMapper (6.0.0)
4 | - Moya (8.0.0):
5 | - Moya/Core (= 8.0.0)
6 | - Moya-ModelMapper/Core (4.1.0):
7 | - ModelMapper
8 | - Moya (~> 8.0.0)
9 | - Moya-ModelMapper/RxSwift (4.1.0):
10 | - Moya-ModelMapper/Core
11 | - Moya/RxSwift (~> 8.0.0)
12 | - RxSwift
13 | - Moya/Core (8.0.0):
14 | - Alamofire (~> 4.2.0)
15 | - Result (~> 3.1.0)
16 | - Moya/RxSwift (8.0.0):
17 | - Moya/Core
18 | - RxSwift (~> 3.1.0)
19 | - Result (3.1.0)
20 | - RxCocoa (3.0.1):
21 | - RxSwift (~> 3.0)
22 | - RxOptional (3.1.3):
23 | - RxCocoa
24 | - RxSwift
25 | - RxSwift (3.1.0)
26 |
27 | DEPENDENCIES:
28 | - Moya-ModelMapper/RxSwift (~> 4.1.0)
29 | - RxCocoa (~> 3.0.0)
30 | - RxOptional
31 |
32 | SPEC CHECKSUMS:
33 | Alamofire: aa2e09d871c9160ac53c90e83c68064a94e3dfbe
34 | ModelMapper: 3596a82f26c43491f6a8d3a00bcdba6ba0e62a93
35 | Moya: 850a166ab8241bd1c1cea6dbe012e3a2ad62944a
36 | Moya-ModelMapper: 7084396138e6f9359881db654ee6a4d826a64f14
37 | Result: 4e3ed5995ed94d0cd6a09be9a431fce3f3624bbf
38 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
39 | RxOptional: b97b59183af80d1e729ac9e51d09a10be668d6a8
40 | RxSwift: 83ff553e7593fdfdcb2562933a64c0284dffdadc
41 |
42 | PODFILE CHECKSUM: e4a627ec7f263cc6d6a1c51a2ef71d795e4e2dca
43 |
44 | COCOAPODS: 1.2.0.rc.1
45 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | // Override point for customization after application launch.
18 | return true
19 | }
20 |
21 | func applicationWillResignActive(_ application: UIApplication) {
22 | // 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.
23 | // 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.
24 | }
25 |
26 | func applicationDidEnterBackground(_ application: UIApplication) {
27 | // 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.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | func applicationWillEnterForeground(_ application: UIApplication) {
32 | // 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.
33 | }
34 |
35 | func applicationDidBecomeActive(_ application: UIApplication) {
36 | // 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.
37 | }
38 |
39 | func applicationWillTerminate(_ application: UIApplication) {
40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/GithubEndpoint.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GithubEndpoint.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 11.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | private extension String {
13 | var URLEscapedString: String {
14 | return self.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlHostAllowed)!
15 | }
16 | }
17 |
18 | enum GitHub {
19 | case userProfile(username: String)
20 | case repos(username: String)
21 | case repo(fullName: String)
22 | case issues(repositoryFullName: String)
23 | }
24 |
25 | extension GitHub: TargetType {
26 | var baseURL: URL { return URL(string: "https://api.github.com")! }
27 | var path: String {
28 | switch self {
29 | case .repos(let name):
30 | return "/users/\(name.URLEscapedString)/repos"
31 | case .userProfile(let name):
32 | return "/users/\(name.URLEscapedString)"
33 | case .repo(let name):
34 | return "/repos/\(name)"
35 | case .issues(let repositoryName):
36 | return "/repos/\(repositoryName)/issues"
37 | }
38 | }
39 | var method: Moya.Method {
40 | return .get
41 | }
42 | var parameters: [String: Any]? {
43 | return nil
44 | }
45 | var sampleData: Data {
46 | switch self {
47 | case .repos(_):
48 | return "{{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}}}".data(using: .utf8)!
49 | case .userProfile(let name):
50 | return "{\"login\": \"\(name)\", \"id\": 100}".data(using: .utf8)!
51 | case .repo(_):
52 | return "{\"id\": \"1\", \"language\": \"Swift\", \"url\": \"https://api.github.com/repos/mjacko/Router\", \"name\": \"Router\"}".data(using: .utf8)!
53 | case .issues(_):
54 | return "{\"id\": 132942471, \"number\": 405, \"title\": \"Updates example with fix to String extension by changing to Optional\", \"body\": \"Fix it pls.\"}".data(using: .utf8)!
55 | }
56 | }
57 | var task: Task {
58 | return .request
59 | }
60 | var parameterEncoding: ParameterEncoding {
61 | return JSONEncoding.default
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/IssueEntity.swift:
--------------------------------------------------------------------------------
1 | //
2 | // IssueEntity.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 11.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import Mapper
10 |
11 | struct Issue: Mappable {
12 |
13 | let identifier: Int
14 | let number: Int
15 | let title: String
16 | let body: String
17 |
18 | init(map: Mapper) throws {
19 | try identifier = map.from("id")
20 | try number = map.from("number")
21 | try title = map.from("title")
22 | try body = map.from("body")
23 | }
24 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/IssueListViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 10.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 | //
9 | // In this project we take more advanced steps, but still quite simple,
10 | // to make working with network layer even more smooth and nice than
11 | // before. Now, with use of Moya/RxSwift/ModelMapper, we will create simple
12 | // model that will handle our logic and we will do everything based on
13 | // Observables. First there is our observable text, which we will cover
14 | // as a computed var to pass it as an observable. Now every time we got a
15 | // signal that the name in the searchbar changed, we will filter it and
16 | // chain with additional steps. First of them would be to call github api
17 | // to verify that the repo exists. If yes, we pass the signal as next
18 | // observable to get the repo issues. Now that we have whole chain
19 | // at the end of the chain if everything worked correctly, we now can
20 | // bind our observable to table view and store it in the cell factory.
21 | // With really little code we have setup really complicated logic, but
22 | // what is more important is that we have done it really smooth, really
23 | // nice and if you have a little bit more experience with Rx, it gets
24 | // really readable.
25 | //
26 |
27 | import Moya
28 | import Moya_ModelMapper
29 | import UIKit
30 | import RxOptional
31 | import RxCocoa
32 | import RxSwift
33 |
34 | class IssueListViewController: UIViewController {
35 |
36 | @IBOutlet weak var tableView: UITableView!
37 | @IBOutlet weak var searchBar: UISearchBar!
38 |
39 | let disposeBag = DisposeBag()
40 | var provider: RxMoyaProvider!
41 | var issueTrackerModel: IssueTrackerModel!
42 |
43 | var latestRepositoryName: Observable {
44 | return searchBar.rx.text
45 | .orEmpty
46 | .debounce(0.5, scheduler: MainScheduler.instance)
47 | .distinctUntilChanged()
48 | }
49 |
50 | override func viewDidLoad() {
51 | super.viewDidLoad()
52 | setupRx()
53 | }
54 |
55 | func setupRx() {
56 | // First part of the puzzle, create our Provider
57 | provider = RxMoyaProvider()
58 |
59 | // Now we will setup our model
60 | issueTrackerModel = IssueTrackerModel(provider: provider, repositoryName: latestRepositoryName)
61 |
62 | // And bind issues to table view
63 | // Here is where the magic happens, with only one binding
64 | // we have filled up about 3 table view data source methods
65 | issueTrackerModel
66 | .trackIssues()
67 | .bindTo(tableView.rx.items) { (tableView, row, item) in
68 | let cell = tableView.dequeueReusableCell(withIdentifier: "issueCell", for: IndexPath(row: row, section: 0))
69 | cell.textLabel?.text = item.title
70 |
71 | return cell
72 | }
73 | .addDisposableTo(disposeBag)
74 |
75 | // Here we tell table view that if user clicks on a cell,
76 | // and the keyboard is still visible, hide it
77 | tableView
78 | .rx.itemSelected
79 | .subscribe(onNext: { indexPath in
80 | if self.searchBar.isFirstResponder == true {
81 | self.view.endEditing(true)
82 | }
83 | })
84 | .addDisposableTo(disposeBag)
85 | }
86 |
87 | func url(_ route: TargetType) -> String {
88 | return route.baseURL.appendingPathComponent(route.path).absoluteString
89 | }
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/IssueTrackerModel.swift:
--------------------------------------------------------------------------------
1 | //
2 | // IssueTrackerModel.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 11.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 | import Mapper
12 | import Moya_ModelMapper
13 | import RxOptional
14 | import RxSwift
15 |
16 | struct IssueTrackerModel {
17 |
18 | let provider: RxMoyaProvider
19 | let repositoryName: Observable
20 |
21 | func trackIssues() -> Observable<[Issue]> {
22 | return repositoryName
23 | .observeOn(MainScheduler.instance)
24 | .flatMapLatest { name -> Observable in
25 | print("Name: \(name)")
26 | return self
27 | .findRepository(name)
28 | }
29 | .flatMapLatest { repository -> Observable<[Issue]?> in
30 | guard let repository = repository else { return Observable.just(nil) }
31 |
32 | print("Repository: \(repository.fullName)")
33 | return self.findIssues(repository)
34 | }
35 | .replaceNilWith([])
36 | }
37 |
38 | internal func findIssues(_ repository: Repository) -> Observable<[Issue]?> {
39 | return self.provider
40 | .request(GitHub.issues(repositoryFullName: repository.fullName))
41 | .debug()
42 | .mapArrayOptional(type: Issue.self)
43 | }
44 |
45 | internal func findRepository(_ name: String) -> Observable {
46 | return self.provider
47 | .request(GitHub.repo(fullName: name))
48 | .debug()
49 | .mapObjectOptional(type: Repository.self)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Libraries Usage/RxMoyaExample/RxMoyaExample/RespositoryEntity.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RespositoryModel.swift
3 | // RxMoyaExample
4 | //
5 | // Created by Lukasz Mroz on 11.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import Mapper
10 |
11 | struct Repository: Mappable {
12 |
13 | let identifier: Int
14 | let language: String
15 | let name: String
16 | let fullName: String
17 |
18 | init(map: Mapper) throws {
19 | try identifier = map.from("id")
20 | try language = map.from("language")
21 | try name = map.from("name")
22 | try fullName = map.from("full_name")
23 | }
24 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '10.0'
2 | use_frameworks!
3 |
4 | post_install do |installer|
5 | installer.pods_project.targets.each do |target|
6 | target.build_configurations.each do |config|
7 | config.build_settings['SWIFT_VERSION'] = '3.0'
8 | config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
9 | end
10 | end
11 | end
12 |
13 |
14 | target 'RxSwiftExample' do
15 | use_frameworks!
16 |
17 | pod 'RxSwift', '~> 3.0.0'
18 | pod 'RxCocoa', '~> 3.0.0'
19 |
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - RxCocoa (3.0.1):
3 | - RxSwift (~> 3.0)
4 | - RxSwift (3.0.1)
5 |
6 | DEPENDENCIES:
7 | - RxCocoa (~> 3.0.0)
8 | - RxSwift (~> 3.0.0)
9 |
10 | SPEC CHECKSUMS:
11 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
12 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
13 |
14 | PODFILE CHECKSUM: 0c9965e2c560e8fd22b517a0c651124429983a7f
15 |
16 | COCOAPODS: 1.1.1
17 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 145302891C68CA6700523766 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 145302881C68CA6700523766 /* AppDelegate.swift */; };
11 | 1453028B1C68CA6700523766 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1453028A1C68CA6700523766 /* ViewController.swift */; };
12 | 1453028E1C68CA6700523766 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1453028C1C68CA6700523766 /* Main.storyboard */; };
13 | 145302901C68CA6700523766 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1453028F1C68CA6700523766 /* Assets.xcassets */; };
14 | 145302931C68CA6700523766 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 145302911C68CA6700523766 /* LaunchScreen.storyboard */; };
15 | 6B89FF8F4A45BC9C46D18722 /* Pods_RxSwiftExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D082D7624360D15BBA84882C /* Pods_RxSwiftExample.framework */; };
16 | /* End PBXBuildFile section */
17 |
18 | /* Begin PBXFileReference section */
19 | 145302851C68CA6700523766 /* RxSwiftExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxSwiftExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
20 | 145302881C68CA6700523766 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
21 | 1453028A1C68CA6700523766 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
22 | 1453028D1C68CA6700523766 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
23 | 1453028F1C68CA6700523766 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
24 | 145302921C68CA6700523766 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
25 | 145302941C68CA6700523766 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
26 | D082D7624360D15BBA84882C /* Pods_RxSwiftExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RxSwiftExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
27 | D17D9107058A398EF6AB0B20 /* Pods-RxSwiftExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxSwiftExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxSwiftExample/Pods-RxSwiftExample.debug.xcconfig"; sourceTree = ""; };
28 | E5A9AC51858B3E04BDA7C767 /* Pods-RxSwiftExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxSwiftExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxSwiftExample/Pods-RxSwiftExample.release.xcconfig"; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | 145302821C68CA6700523766 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | 6B89FF8F4A45BC9C46D18722 /* Pods_RxSwiftExample.framework in Frameworks */,
37 | );
38 | runOnlyForDeploymentPostprocessing = 0;
39 | };
40 | /* End PBXFrameworksBuildPhase section */
41 |
42 | /* Begin PBXGroup section */
43 | 1453027C1C68CA6700523766 = {
44 | isa = PBXGroup;
45 | children = (
46 | 145302871C68CA6700523766 /* RxSwiftExample */,
47 | 145302861C68CA6700523766 /* Products */,
48 | 6FEE991E60322A28CFB44613 /* Pods */,
49 | 7C315870A2935346A9BEC28A /* Frameworks */,
50 | );
51 | sourceTree = "";
52 | };
53 | 145302861C68CA6700523766 /* Products */ = {
54 | isa = PBXGroup;
55 | children = (
56 | 145302851C68CA6700523766 /* RxSwiftExample.app */,
57 | );
58 | name = Products;
59 | sourceTree = "";
60 | };
61 | 145302871C68CA6700523766 /* RxSwiftExample */ = {
62 | isa = PBXGroup;
63 | children = (
64 | 145302881C68CA6700523766 /* AppDelegate.swift */,
65 | 1453028A1C68CA6700523766 /* ViewController.swift */,
66 | 1453028C1C68CA6700523766 /* Main.storyboard */,
67 | 1453028F1C68CA6700523766 /* Assets.xcassets */,
68 | 145302911C68CA6700523766 /* LaunchScreen.storyboard */,
69 | 145302941C68CA6700523766 /* Info.plist */,
70 | );
71 | path = RxSwiftExample;
72 | sourceTree = "";
73 | };
74 | 6FEE991E60322A28CFB44613 /* Pods */ = {
75 | isa = PBXGroup;
76 | children = (
77 | D17D9107058A398EF6AB0B20 /* Pods-RxSwiftExample.debug.xcconfig */,
78 | E5A9AC51858B3E04BDA7C767 /* Pods-RxSwiftExample.release.xcconfig */,
79 | );
80 | name = Pods;
81 | sourceTree = "";
82 | };
83 | 7C315870A2935346A9BEC28A /* Frameworks */ = {
84 | isa = PBXGroup;
85 | children = (
86 | D082D7624360D15BBA84882C /* Pods_RxSwiftExample.framework */,
87 | );
88 | name = Frameworks;
89 | sourceTree = "";
90 | };
91 | /* End PBXGroup section */
92 |
93 | /* Begin PBXNativeTarget section */
94 | 145302841C68CA6700523766 /* RxSwiftExample */ = {
95 | isa = PBXNativeTarget;
96 | buildConfigurationList = 145302971C68CA6700523766 /* Build configuration list for PBXNativeTarget "RxSwiftExample" */;
97 | buildPhases = (
98 | 44D141083F8F7FC05DE9861A /* [CP] Check Pods Manifest.lock */,
99 | 145302811C68CA6700523766 /* Sources */,
100 | 145302821C68CA6700523766 /* Frameworks */,
101 | 145302831C68CA6700523766 /* Resources */,
102 | 8BEBF9DBFF145F6F2DD8F575 /* [CP] Embed Pods Frameworks */,
103 | E0717E45D05493281766DA2A /* [CP] Copy Pods Resources */,
104 | );
105 | buildRules = (
106 | );
107 | dependencies = (
108 | );
109 | name = RxSwiftExample;
110 | productName = RxSwiftExample;
111 | productReference = 145302851C68CA6700523766 /* RxSwiftExample.app */;
112 | productType = "com.apple.product-type.application";
113 | };
114 | /* End PBXNativeTarget section */
115 |
116 | /* Begin PBXProject section */
117 | 1453027D1C68CA6700523766 /* Project object */ = {
118 | isa = PBXProject;
119 | attributes = {
120 | LastSwiftUpdateCheck = 0720;
121 | LastUpgradeCheck = 0800;
122 | ORGANIZATIONNAME = "Droids on Roids";
123 | TargetAttributes = {
124 | 145302841C68CA6700523766 = {
125 | CreatedOnToolsVersion = 7.2.1;
126 | LastSwiftMigration = 0800;
127 | };
128 | };
129 | };
130 | buildConfigurationList = 145302801C68CA6700523766 /* Build configuration list for PBXProject "RxSwiftExample" */;
131 | compatibilityVersion = "Xcode 3.2";
132 | developmentRegion = English;
133 | hasScannedForEncodings = 0;
134 | knownRegions = (
135 | en,
136 | Base,
137 | );
138 | mainGroup = 1453027C1C68CA6700523766;
139 | productRefGroup = 145302861C68CA6700523766 /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | 145302841C68CA6700523766 /* RxSwiftExample */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXResourcesBuildPhase section */
149 | 145302831C68CA6700523766 /* Resources */ = {
150 | isa = PBXResourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | 145302931C68CA6700523766 /* LaunchScreen.storyboard in Resources */,
154 | 145302901C68CA6700523766 /* Assets.xcassets in Resources */,
155 | 1453028E1C68CA6700523766 /* Main.storyboard in Resources */,
156 | );
157 | runOnlyForDeploymentPostprocessing = 0;
158 | };
159 | /* End PBXResourcesBuildPhase section */
160 |
161 | /* Begin PBXShellScriptBuildPhase section */
162 | 44D141083F8F7FC05DE9861A /* [CP] Check Pods Manifest.lock */ = {
163 | isa = PBXShellScriptBuildPhase;
164 | buildActionMask = 2147483647;
165 | files = (
166 | );
167 | inputPaths = (
168 | );
169 | name = "[CP] Check Pods Manifest.lock";
170 | outputPaths = (
171 | );
172 | runOnlyForDeploymentPostprocessing = 0;
173 | shellPath = /bin/sh;
174 | 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";
175 | showEnvVarsInLog = 0;
176 | };
177 | 8BEBF9DBFF145F6F2DD8F575 /* [CP] Embed Pods Frameworks */ = {
178 | isa = PBXShellScriptBuildPhase;
179 | buildActionMask = 2147483647;
180 | files = (
181 | );
182 | inputPaths = (
183 | );
184 | name = "[CP] Embed Pods Frameworks";
185 | outputPaths = (
186 | );
187 | runOnlyForDeploymentPostprocessing = 0;
188 | shellPath = /bin/sh;
189 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxSwiftExample/Pods-RxSwiftExample-frameworks.sh\"\n";
190 | showEnvVarsInLog = 0;
191 | };
192 | E0717E45D05493281766DA2A /* [CP] Copy Pods Resources */ = {
193 | isa = PBXShellScriptBuildPhase;
194 | buildActionMask = 2147483647;
195 | files = (
196 | );
197 | inputPaths = (
198 | );
199 | name = "[CP] Copy Pods Resources";
200 | outputPaths = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | shellPath = /bin/sh;
204 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxSwiftExample/Pods-RxSwiftExample-resources.sh\"\n";
205 | showEnvVarsInLog = 0;
206 | };
207 | /* End PBXShellScriptBuildPhase section */
208 |
209 | /* Begin PBXSourcesBuildPhase section */
210 | 145302811C68CA6700523766 /* Sources */ = {
211 | isa = PBXSourcesBuildPhase;
212 | buildActionMask = 2147483647;
213 | files = (
214 | 1453028B1C68CA6700523766 /* ViewController.swift in Sources */,
215 | 145302891C68CA6700523766 /* AppDelegate.swift in Sources */,
216 | );
217 | runOnlyForDeploymentPostprocessing = 0;
218 | };
219 | /* End PBXSourcesBuildPhase section */
220 |
221 | /* Begin PBXVariantGroup section */
222 | 1453028C1C68CA6700523766 /* Main.storyboard */ = {
223 | isa = PBXVariantGroup;
224 | children = (
225 | 1453028D1C68CA6700523766 /* Base */,
226 | );
227 | name = Main.storyboard;
228 | sourceTree = "";
229 | };
230 | 145302911C68CA6700523766 /* LaunchScreen.storyboard */ = {
231 | isa = PBXVariantGroup;
232 | children = (
233 | 145302921C68CA6700523766 /* Base */,
234 | );
235 | name = LaunchScreen.storyboard;
236 | sourceTree = "";
237 | };
238 | /* End PBXVariantGroup section */
239 |
240 | /* Begin XCBuildConfiguration section */
241 | 145302951C68CA6700523766 /* Debug */ = {
242 | isa = XCBuildConfiguration;
243 | buildSettings = {
244 | ALWAYS_SEARCH_USER_PATHS = NO;
245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
246 | CLANG_CXX_LIBRARY = "libc++";
247 | CLANG_ENABLE_MODULES = YES;
248 | CLANG_ENABLE_OBJC_ARC = YES;
249 | CLANG_WARN_BOOL_CONVERSION = YES;
250 | CLANG_WARN_CONSTANT_CONVERSION = YES;
251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
252 | CLANG_WARN_EMPTY_BODY = YES;
253 | CLANG_WARN_ENUM_CONVERSION = YES;
254 | CLANG_WARN_INFINITE_RECURSION = YES;
255 | CLANG_WARN_INT_CONVERSION = YES;
256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
257 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
258 | CLANG_WARN_UNREACHABLE_CODE = YES;
259 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
260 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
261 | COPY_PHASE_STRIP = NO;
262 | DEBUG_INFORMATION_FORMAT = dwarf;
263 | ENABLE_STRICT_OBJC_MSGSEND = YES;
264 | ENABLE_TESTABILITY = YES;
265 | GCC_C_LANGUAGE_STANDARD = gnu99;
266 | GCC_DYNAMIC_NO_PIC = NO;
267 | GCC_NO_COMMON_BLOCKS = YES;
268 | GCC_OPTIMIZATION_LEVEL = 0;
269 | GCC_PREPROCESSOR_DEFINITIONS = (
270 | "DEBUG=1",
271 | "$(inherited)",
272 | );
273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
275 | GCC_WARN_UNDECLARED_SELECTOR = YES;
276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
277 | GCC_WARN_UNUSED_FUNCTION = YES;
278 | GCC_WARN_UNUSED_VARIABLE = YES;
279 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
280 | MTL_ENABLE_DEBUG_INFO = YES;
281 | ONLY_ACTIVE_ARCH = YES;
282 | SDKROOT = iphoneos;
283 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
284 | };
285 | name = Debug;
286 | };
287 | 145302961C68CA6700523766 /* Release */ = {
288 | isa = XCBuildConfiguration;
289 | buildSettings = {
290 | ALWAYS_SEARCH_USER_PATHS = NO;
291 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
292 | CLANG_CXX_LIBRARY = "libc++";
293 | CLANG_ENABLE_MODULES = YES;
294 | CLANG_ENABLE_OBJC_ARC = YES;
295 | CLANG_WARN_BOOL_CONVERSION = YES;
296 | CLANG_WARN_CONSTANT_CONVERSION = YES;
297 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
298 | CLANG_WARN_EMPTY_BODY = YES;
299 | CLANG_WARN_ENUM_CONVERSION = YES;
300 | CLANG_WARN_INFINITE_RECURSION = YES;
301 | CLANG_WARN_INT_CONVERSION = YES;
302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
303 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
304 | CLANG_WARN_UNREACHABLE_CODE = YES;
305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
306 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
307 | COPY_PHASE_STRIP = NO;
308 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
309 | ENABLE_NS_ASSERTIONS = NO;
310 | ENABLE_STRICT_OBJC_MSGSEND = YES;
311 | GCC_C_LANGUAGE_STANDARD = gnu99;
312 | GCC_NO_COMMON_BLOCKS = YES;
313 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
314 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
315 | GCC_WARN_UNDECLARED_SELECTOR = YES;
316 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
317 | GCC_WARN_UNUSED_FUNCTION = YES;
318 | GCC_WARN_UNUSED_VARIABLE = YES;
319 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
320 | MTL_ENABLE_DEBUG_INFO = NO;
321 | SDKROOT = iphoneos;
322 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
323 | VALIDATE_PRODUCT = YES;
324 | };
325 | name = Release;
326 | };
327 | 145302981C68CA6700523766 /* Debug */ = {
328 | isa = XCBuildConfiguration;
329 | baseConfigurationReference = D17D9107058A398EF6AB0B20 /* Pods-RxSwiftExample.debug.xcconfig */;
330 | buildSettings = {
331 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
332 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
333 | INFOPLIST_FILE = RxSwiftExample/Info.plist;
334 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
335 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxSwiftExample;
336 | PRODUCT_NAME = "$(TARGET_NAME)";
337 | SWIFT_VERSION = 3.0;
338 | };
339 | name = Debug;
340 | };
341 | 145302991C68CA6700523766 /* Release */ = {
342 | isa = XCBuildConfiguration;
343 | baseConfigurationReference = E5A9AC51858B3E04BDA7C767 /* Pods-RxSwiftExample.release.xcconfig */;
344 | buildSettings = {
345 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
346 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
347 | INFOPLIST_FILE = RxSwiftExample/Info.plist;
348 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
349 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxSwiftExample;
350 | PRODUCT_NAME = "$(TARGET_NAME)";
351 | SWIFT_VERSION = 3.0;
352 | };
353 | name = Release;
354 | };
355 | /* End XCBuildConfiguration section */
356 |
357 | /* Begin XCConfigurationList section */
358 | 145302801C68CA6700523766 /* Build configuration list for PBXProject "RxSwiftExample" */ = {
359 | isa = XCConfigurationList;
360 | buildConfigurations = (
361 | 145302951C68CA6700523766 /* Debug */,
362 | 145302961C68CA6700523766 /* Release */,
363 | );
364 | defaultConfigurationIsVisible = 0;
365 | defaultConfigurationName = Release;
366 | };
367 | 145302971C68CA6700523766 /* Build configuration list for PBXNativeTarget "RxSwiftExample" */ = {
368 | isa = XCConfigurationList;
369 | buildConfigurations = (
370 | 145302981C68CA6700523766 /* Debug */,
371 | 145302991C68CA6700523766 /* Release */,
372 | );
373 | defaultConfigurationIsVisible = 0;
374 | defaultConfigurationName = Release;
375 | };
376 | /* End XCConfigurationList section */
377 | };
378 | rootObject = 1453027D1C68CA6700523766 /* Project object */;
379 | }
380 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxSwiftExample
4 | //
5 | // Created by Lukasz Mroz on 08.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxSwiftExample/RxSwiftExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxSwiftExample
4 | //
5 | // Created by Lukasz Mroz on 08.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 | //
9 | //
10 | // Here we have basic example of RxSwift. UI is pretty simple, take a look at Main.storyboard.
11 | // It is basically UISearchBar + UITableView. The main idea of this app is that every time
12 | // someone types something in the search bar, we want to get the cities from API that starts
13 | // with the letters someone typed. The main problems here are:
14 | // a) What if the text(here query) in search bar is empty?
15 | // b) What if someone will spam API by continuesly changing letters?
16 | //
17 | // We want to be safe with our app so we will filter the empty queries to protect against a).
18 | // About the b), we will use RxSwift's debounce() & distinctUntilChanged(). The first one
19 | // waits given time for a change. If the change occured before the time given, timer will reset
20 | // and Rx will wait again for a change. If change didn't happen in specified time, the next value
21 | // will go through. Basically it means that we will wait X time before sending API request, if someone
22 | // changed his mind (or just spam), we will wait patiently. If not, we will just do the API request.
23 | // Second function distinctUntilChanged() will protect us against searching the same phrase again.
24 | // So if someone type A, then will type AB and go back to A, we will not fire another request (it is
25 | // just in our case that we want that behavior, if you have dynamically changed fields, you better
26 | // leave this function).
27 | //
28 |
29 | import UIKit
30 | import RxCocoa
31 | import RxSwift
32 |
33 | class ViewController: UIViewController {
34 |
35 | @IBOutlet weak var tableView: UITableView!
36 | @IBOutlet weak var searchBar: UISearchBar!
37 |
38 | var shownCities = [String]() // Data source for UITableView
39 | let allCities = ["New York", "London", "Oslo", "Warsaw", "Berlin", "Praga"] // Our mocked API data source
40 | let disposeBag = DisposeBag() // Bag of disposables to release them when view is being deallocated
41 | override func viewDidLoad() {
42 | super.viewDidLoad()
43 | setup()
44 | }
45 |
46 | func setup() {
47 | tableView.dataSource = self
48 | searchBar
49 | .rx.text // Observable property thanks to RxCocoa
50 | .orEmpty // Make it non-optional
51 | .debounce(0.5, scheduler: MainScheduler.instance) // Wait 0.5 for changes.
52 | .distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
53 | .filter { !$0.isEmpty } // If the new value is really new, filter for non-empty query.
54 | .subscribe(onNext: { [unowned self] query in // Here we subscribe to every new value, that is not empty (thanks to filter above).
55 | self.shownCities = self.allCities.filter { $0.hasPrefix(query) } // We now do our "API Request" to find cities.
56 | self.tableView.reloadData() // And reload table view data.
57 | })
58 | .addDisposableTo(disposeBag) // Don't forget to add this to disposeBag. We want to dispose it on deinit.
59 | }
60 |
61 | }
62 |
63 | // MARK: - UITableViewDataSource
64 | /// Here we have standard data source extension for ViewController
65 | extension ViewController: UITableViewDataSource {
66 |
67 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
68 | return shownCities.count
69 | }
70 |
71 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
72 | let cell = tableView.dequeueReusableCell(withIdentifier: "cityPrototypeCell", for: indexPath)
73 | cell.textLabel?.text = shownCities[indexPath.row]
74 |
75 | return cell
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | use_frameworks!
3 |
4 | target 'RxWebKitExample' do
5 |
6 | pod 'RxWebKit', "~> 0.3.3"
7 |
8 | end
9 |
10 | post_install do |installer|
11 | installer.pods_project.targets.each do |target|
12 | target.build_configurations.each do |config|
13 | if config.name == 'Debug'
14 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
15 | config.build_settings['SWIFT_VERSION'] = '3.0'
16 | end
17 | end
18 | end
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - RxCocoa (3.0.1):
3 | - RxSwift (~> 3.0)
4 | - RxSwift (3.0.1)
5 | - RxWebKit (0.3.3):
6 | - RxCocoa (~> 3.0.0)
7 | - RxSwift (~> 3.0.0)
8 |
9 | DEPENDENCIES:
10 | - RxWebKit (~> 0.3.3)
11 |
12 | SPEC CHECKSUMS:
13 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
14 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
15 | RxWebKit: d237746fede36ebe8b94e724cabab5b00d8174e3
16 |
17 | PODFILE CHECKSUM: d5d493c800aa512e21978083c503143b71566444
18 |
19 | COCOAPODS: 1.1.1
20 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1484F5381C72AA3D0086E6EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1484F5371C72AA3D0086E6EE /* AppDelegate.swift */; };
11 | 1484F53A1C72AA3D0086E6EE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1484F5391C72AA3D0086E6EE /* ViewController.swift */; };
12 | 1484F53D1C72AA3D0086E6EE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1484F53B1C72AA3D0086E6EE /* Main.storyboard */; };
13 | 1484F53F1C72AA3D0086E6EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1484F53E1C72AA3D0086E6EE /* Assets.xcassets */; };
14 | 1484F5421C72AA3D0086E6EE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1484F5401C72AA3D0086E6EE /* LaunchScreen.storyboard */; };
15 | F6FB268858BBCE8BF50BFD44 /* Pods_RxWebKitExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7DFA599E6EC1C15E3270FB3 /* Pods_RxWebKitExample.framework */; };
16 | /* End PBXBuildFile section */
17 |
18 | /* Begin PBXFileReference section */
19 | 1484F5341C72AA3D0086E6EE /* RxWebKitExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxWebKitExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
20 | 1484F5371C72AA3D0086E6EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
21 | 1484F5391C72AA3D0086E6EE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
22 | 1484F53C1C72AA3D0086E6EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
23 | 1484F53E1C72AA3D0086E6EE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
24 | 1484F5411C72AA3D0086E6EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
25 | 1484F5431C72AA3D0086E6EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
26 | A3A36A87AC63E2D5C45CDD96 /* Pods-RxWebKitExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxWebKitExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxWebKitExample/Pods-RxWebKitExample.debug.xcconfig"; sourceTree = ""; };
27 | C7DFA599E6EC1C15E3270FB3 /* Pods_RxWebKitExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RxWebKitExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
28 | EB9E4A0E249009FEAC014509 /* Pods-RxWebKitExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxWebKitExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxWebKitExample/Pods-RxWebKitExample.release.xcconfig"; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | 1484F5311C72AA3D0086E6EE /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | F6FB268858BBCE8BF50BFD44 /* Pods_RxWebKitExample.framework in Frameworks */,
37 | );
38 | runOnlyForDeploymentPostprocessing = 0;
39 | };
40 | /* End PBXFrameworksBuildPhase section */
41 |
42 | /* Begin PBXGroup section */
43 | 1484F52B1C72AA3D0086E6EE = {
44 | isa = PBXGroup;
45 | children = (
46 | 1484F5361C72AA3D0086E6EE /* RxWebKitExample */,
47 | 1484F5351C72AA3D0086E6EE /* Products */,
48 | 2CA8A4C193A5A716252EFA80 /* Pods */,
49 | C544923D8B2B7BC2EFF8732D /* Frameworks */,
50 | );
51 | sourceTree = "";
52 | };
53 | 1484F5351C72AA3D0086E6EE /* Products */ = {
54 | isa = PBXGroup;
55 | children = (
56 | 1484F5341C72AA3D0086E6EE /* RxWebKitExample.app */,
57 | );
58 | name = Products;
59 | sourceTree = "";
60 | };
61 | 1484F5361C72AA3D0086E6EE /* RxWebKitExample */ = {
62 | isa = PBXGroup;
63 | children = (
64 | 1484F5371C72AA3D0086E6EE /* AppDelegate.swift */,
65 | 1484F5391C72AA3D0086E6EE /* ViewController.swift */,
66 | 1484F53B1C72AA3D0086E6EE /* Main.storyboard */,
67 | 1484F53E1C72AA3D0086E6EE /* Assets.xcassets */,
68 | 1484F5401C72AA3D0086E6EE /* LaunchScreen.storyboard */,
69 | 1484F5431C72AA3D0086E6EE /* Info.plist */,
70 | );
71 | path = RxWebKitExample;
72 | sourceTree = "";
73 | };
74 | 2CA8A4C193A5A716252EFA80 /* Pods */ = {
75 | isa = PBXGroup;
76 | children = (
77 | A3A36A87AC63E2D5C45CDD96 /* Pods-RxWebKitExample.debug.xcconfig */,
78 | EB9E4A0E249009FEAC014509 /* Pods-RxWebKitExample.release.xcconfig */,
79 | );
80 | name = Pods;
81 | sourceTree = "";
82 | };
83 | C544923D8B2B7BC2EFF8732D /* Frameworks */ = {
84 | isa = PBXGroup;
85 | children = (
86 | C7DFA599E6EC1C15E3270FB3 /* Pods_RxWebKitExample.framework */,
87 | );
88 | name = Frameworks;
89 | sourceTree = "";
90 | };
91 | /* End PBXGroup section */
92 |
93 | /* Begin PBXNativeTarget section */
94 | 1484F5331C72AA3D0086E6EE /* RxWebKitExample */ = {
95 | isa = PBXNativeTarget;
96 | buildConfigurationList = 1484F5461C72AA3D0086E6EE /* Build configuration list for PBXNativeTarget "RxWebKitExample" */;
97 | buildPhases = (
98 | 7624B040C1487B8B24467420 /* [CP] Check Pods Manifest.lock */,
99 | 1484F5301C72AA3D0086E6EE /* Sources */,
100 | 1484F5311C72AA3D0086E6EE /* Frameworks */,
101 | 1484F5321C72AA3D0086E6EE /* Resources */,
102 | 711E7B02A7599FF371296295 /* [CP] Embed Pods Frameworks */,
103 | 9C66C9B5171DD7100A9899FB /* [CP] Copy Pods Resources */,
104 | );
105 | buildRules = (
106 | );
107 | dependencies = (
108 | );
109 | name = RxWebKitExample;
110 | productName = RxWebKitExample;
111 | productReference = 1484F5341C72AA3D0086E6EE /* RxWebKitExample.app */;
112 | productType = "com.apple.product-type.application";
113 | };
114 | /* End PBXNativeTarget section */
115 |
116 | /* Begin PBXProject section */
117 | 1484F52C1C72AA3D0086E6EE /* Project object */ = {
118 | isa = PBXProject;
119 | attributes = {
120 | LastSwiftUpdateCheck = 0720;
121 | LastUpgradeCheck = 0720;
122 | ORGANIZATIONNAME = "Droids on Roids";
123 | TargetAttributes = {
124 | 1484F5331C72AA3D0086E6EE = {
125 | CreatedOnToolsVersion = 7.2.1;
126 | LastSwiftMigration = 0810;
127 | };
128 | };
129 | };
130 | buildConfigurationList = 1484F52F1C72AA3D0086E6EE /* Build configuration list for PBXProject "RxWebKitExample" */;
131 | compatibilityVersion = "Xcode 3.2";
132 | developmentRegion = English;
133 | hasScannedForEncodings = 0;
134 | knownRegions = (
135 | en,
136 | Base,
137 | );
138 | mainGroup = 1484F52B1C72AA3D0086E6EE;
139 | productRefGroup = 1484F5351C72AA3D0086E6EE /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | 1484F5331C72AA3D0086E6EE /* RxWebKitExample */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXResourcesBuildPhase section */
149 | 1484F5321C72AA3D0086E6EE /* Resources */ = {
150 | isa = PBXResourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | 1484F5421C72AA3D0086E6EE /* LaunchScreen.storyboard in Resources */,
154 | 1484F53F1C72AA3D0086E6EE /* Assets.xcassets in Resources */,
155 | 1484F53D1C72AA3D0086E6EE /* Main.storyboard in Resources */,
156 | );
157 | runOnlyForDeploymentPostprocessing = 0;
158 | };
159 | /* End PBXResourcesBuildPhase section */
160 |
161 | /* Begin PBXShellScriptBuildPhase section */
162 | 711E7B02A7599FF371296295 /* [CP] Embed Pods Frameworks */ = {
163 | isa = PBXShellScriptBuildPhase;
164 | buildActionMask = 2147483647;
165 | files = (
166 | );
167 | inputPaths = (
168 | );
169 | name = "[CP] Embed Pods Frameworks";
170 | outputPaths = (
171 | );
172 | runOnlyForDeploymentPostprocessing = 0;
173 | shellPath = /bin/sh;
174 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxWebKitExample/Pods-RxWebKitExample-frameworks.sh\"\n";
175 | showEnvVarsInLog = 0;
176 | };
177 | 7624B040C1487B8B24467420 /* [CP] Check Pods Manifest.lock */ = {
178 | isa = PBXShellScriptBuildPhase;
179 | buildActionMask = 2147483647;
180 | files = (
181 | );
182 | inputPaths = (
183 | );
184 | name = "[CP] Check Pods Manifest.lock";
185 | outputPaths = (
186 | );
187 | runOnlyForDeploymentPostprocessing = 0;
188 | shellPath = /bin/sh;
189 | 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";
190 | showEnvVarsInLog = 0;
191 | };
192 | 9C66C9B5171DD7100A9899FB /* [CP] Copy Pods Resources */ = {
193 | isa = PBXShellScriptBuildPhase;
194 | buildActionMask = 2147483647;
195 | files = (
196 | );
197 | inputPaths = (
198 | );
199 | name = "[CP] Copy Pods Resources";
200 | outputPaths = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | shellPath = /bin/sh;
204 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxWebKitExample/Pods-RxWebKitExample-resources.sh\"\n";
205 | showEnvVarsInLog = 0;
206 | };
207 | /* End PBXShellScriptBuildPhase section */
208 |
209 | /* Begin PBXSourcesBuildPhase section */
210 | 1484F5301C72AA3D0086E6EE /* Sources */ = {
211 | isa = PBXSourcesBuildPhase;
212 | buildActionMask = 2147483647;
213 | files = (
214 | 1484F53A1C72AA3D0086E6EE /* ViewController.swift in Sources */,
215 | 1484F5381C72AA3D0086E6EE /* AppDelegate.swift in Sources */,
216 | );
217 | runOnlyForDeploymentPostprocessing = 0;
218 | };
219 | /* End PBXSourcesBuildPhase section */
220 |
221 | /* Begin PBXVariantGroup section */
222 | 1484F53B1C72AA3D0086E6EE /* Main.storyboard */ = {
223 | isa = PBXVariantGroup;
224 | children = (
225 | 1484F53C1C72AA3D0086E6EE /* Base */,
226 | );
227 | name = Main.storyboard;
228 | sourceTree = "";
229 | };
230 | 1484F5401C72AA3D0086E6EE /* LaunchScreen.storyboard */ = {
231 | isa = PBXVariantGroup;
232 | children = (
233 | 1484F5411C72AA3D0086E6EE /* Base */,
234 | );
235 | name = LaunchScreen.storyboard;
236 | sourceTree = "";
237 | };
238 | /* End PBXVariantGroup section */
239 |
240 | /* Begin XCBuildConfiguration section */
241 | 1484F5441C72AA3D0086E6EE /* Debug */ = {
242 | isa = XCBuildConfiguration;
243 | buildSettings = {
244 | ALWAYS_SEARCH_USER_PATHS = NO;
245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
246 | CLANG_CXX_LIBRARY = "libc++";
247 | CLANG_ENABLE_MODULES = YES;
248 | CLANG_ENABLE_OBJC_ARC = YES;
249 | CLANG_WARN_BOOL_CONVERSION = YES;
250 | CLANG_WARN_CONSTANT_CONVERSION = YES;
251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
252 | CLANG_WARN_EMPTY_BODY = YES;
253 | CLANG_WARN_ENUM_CONVERSION = YES;
254 | CLANG_WARN_INT_CONVERSION = YES;
255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
256 | CLANG_WARN_UNREACHABLE_CODE = YES;
257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
259 | COPY_PHASE_STRIP = NO;
260 | DEBUG_INFORMATION_FORMAT = dwarf;
261 | ENABLE_STRICT_OBJC_MSGSEND = YES;
262 | ENABLE_TESTABILITY = YES;
263 | GCC_C_LANGUAGE_STANDARD = gnu99;
264 | GCC_DYNAMIC_NO_PIC = NO;
265 | GCC_NO_COMMON_BLOCKS = YES;
266 | GCC_OPTIMIZATION_LEVEL = 0;
267 | GCC_PREPROCESSOR_DEFINITIONS = (
268 | "DEBUG=1",
269 | "$(inherited)",
270 | );
271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
273 | GCC_WARN_UNDECLARED_SELECTOR = YES;
274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
275 | GCC_WARN_UNUSED_FUNCTION = YES;
276 | GCC_WARN_UNUSED_VARIABLE = YES;
277 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
278 | MTL_ENABLE_DEBUG_INFO = YES;
279 | ONLY_ACTIVE_ARCH = YES;
280 | SDKROOT = iphoneos;
281 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
282 | };
283 | name = Debug;
284 | };
285 | 1484F5451C72AA3D0086E6EE /* Release */ = {
286 | isa = XCBuildConfiguration;
287 | buildSettings = {
288 | ALWAYS_SEARCH_USER_PATHS = NO;
289 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
290 | CLANG_CXX_LIBRARY = "libc++";
291 | CLANG_ENABLE_MODULES = YES;
292 | CLANG_ENABLE_OBJC_ARC = YES;
293 | CLANG_WARN_BOOL_CONVERSION = YES;
294 | CLANG_WARN_CONSTANT_CONVERSION = YES;
295 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
296 | CLANG_WARN_EMPTY_BODY = YES;
297 | CLANG_WARN_ENUM_CONVERSION = YES;
298 | CLANG_WARN_INT_CONVERSION = YES;
299 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
300 | CLANG_WARN_UNREACHABLE_CODE = YES;
301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
303 | COPY_PHASE_STRIP = NO;
304 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
305 | ENABLE_NS_ASSERTIONS = NO;
306 | ENABLE_STRICT_OBJC_MSGSEND = YES;
307 | GCC_C_LANGUAGE_STANDARD = gnu99;
308 | GCC_NO_COMMON_BLOCKS = YES;
309 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
310 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
311 | GCC_WARN_UNDECLARED_SELECTOR = YES;
312 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
313 | GCC_WARN_UNUSED_FUNCTION = YES;
314 | GCC_WARN_UNUSED_VARIABLE = YES;
315 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
316 | MTL_ENABLE_DEBUG_INFO = NO;
317 | SDKROOT = iphoneos;
318 | VALIDATE_PRODUCT = YES;
319 | };
320 | name = Release;
321 | };
322 | 1484F5471C72AA3D0086E6EE /* Debug */ = {
323 | isa = XCBuildConfiguration;
324 | baseConfigurationReference = A3A36A87AC63E2D5C45CDD96 /* Pods-RxWebKitExample.debug.xcconfig */;
325 | buildSettings = {
326 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
327 | INFOPLIST_FILE = RxWebKitExample/Info.plist;
328 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
329 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxWebKitExample;
330 | PRODUCT_NAME = "$(TARGET_NAME)";
331 | SWIFT_VERSION = 3.0;
332 | };
333 | name = Debug;
334 | };
335 | 1484F5481C72AA3D0086E6EE /* Release */ = {
336 | isa = XCBuildConfiguration;
337 | baseConfigurationReference = EB9E4A0E249009FEAC014509 /* Pods-RxWebKitExample.release.xcconfig */;
338 | buildSettings = {
339 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
340 | INFOPLIST_FILE = RxWebKitExample/Info.plist;
341 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
342 | PRODUCT_BUNDLE_IDENTIFIER = com.droidsonroids.RxWebKitExample;
343 | PRODUCT_NAME = "$(TARGET_NAME)";
344 | SWIFT_VERSION = 3.0;
345 | };
346 | name = Release;
347 | };
348 | /* End XCBuildConfiguration section */
349 |
350 | /* Begin XCConfigurationList section */
351 | 1484F52F1C72AA3D0086E6EE /* Build configuration list for PBXProject "RxWebKitExample" */ = {
352 | isa = XCConfigurationList;
353 | buildConfigurations = (
354 | 1484F5441C72AA3D0086E6EE /* Debug */,
355 | 1484F5451C72AA3D0086E6EE /* Release */,
356 | );
357 | defaultConfigurationIsVisible = 0;
358 | defaultConfigurationName = Release;
359 | };
360 | 1484F5461C72AA3D0086E6EE /* Build configuration list for PBXNativeTarget "RxWebKitExample" */ = {
361 | isa = XCConfigurationList;
362 | buildConfigurations = (
363 | 1484F5471C72AA3D0086E6EE /* Debug */,
364 | 1484F5481C72AA3D0086E6EE /* Release */,
365 | );
366 | defaultConfigurationIsVisible = 0;
367 | defaultConfigurationName = Release;
368 | };
369 | /* End XCConfigurationList section */
370 | };
371 | rootObject = 1484F52C1C72AA3D0086E6EE /* Project object */;
372 | }
373 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxWebKitExample
4 | //
5 | // Created by Lukasz Mroz on 16.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 | // Override point for customization after application launch.
18 | return true
19 | }
20 |
21 | func applicationWillResignActive(_ application: UIApplication) {
22 | // 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.
23 | // 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.
24 | }
25 |
26 | func applicationDidEnterBackground(_ application: UIApplication) {
27 | // 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.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | func applicationWillEnterForeground(_ application: UIApplication) {
32 | // 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.
33 | }
34 |
35 | func applicationDidBecomeActive(_ application: UIApplication) {
36 | // 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.
37 | }
38 |
39 | func applicationWillTerminate(_ application: UIApplication) {
40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41 | }
42 |
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Libraries Usage/RxWebKitExample/RxWebKitExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxWebKitExample
4 | //
5 | // Created by Lukasz Mroz on 16.02.2016.
6 | // Copyright © 2016 Droids on Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import RxCocoa
11 | import RxSwift
12 | import RxWebKit
13 | import WebKit
14 |
15 | class ViewController: UIViewController {
16 |
17 | @IBOutlet weak var searchBar: UISearchBar!
18 | @IBOutlet weak var webViewWrapper: UIView!
19 |
20 | var webView: WKWebView!
21 | let disposeBag = DisposeBag()
22 |
23 | override func viewDidLoad() {
24 | super.viewDidLoad()
25 | setupUI()
26 | setupRx()
27 | }
28 |
29 | override func viewDidLayoutSubviews() {
30 | super.viewDidLayoutSubviews()
31 | setupResizing()
32 | }
33 |
34 | func setupUI() {
35 | webView = WKWebView(frame: webViewWrapper.frame)
36 | webViewWrapper.addSubview(webView)
37 | searchBar.text = "https://github.com/ReactiveX/RxSwift"
38 | }
39 |
40 | func setupResizing() {
41 | webView.frame = webViewWrapper.frame
42 | webView.frame.origin = CGPoint.zero
43 | }
44 |
45 | func setupRx() {
46 | webView.rx.title
47 | .filter { $0 != nil }
48 | .map { $0! }
49 | .filter { $0.characters.count > 0 }
50 | .subscribe(onNext: { title in
51 | self.title = title
52 | })
53 | .addDisposableTo(disposeBag)
54 |
55 | searchBar.rx.text
56 | .filter { $0 != nil }
57 | .map { $0! }
58 | .debounce(0.5, scheduler: MainScheduler.instance)
59 | .distinctUntilChanged()
60 | .filter { URL(string: $0) != nil }
61 | .map { URL(string: $0)! }
62 | .subscribe(onNext: { url in
63 | self.webView.load(URLRequest(url: url))
64 | })
65 | .addDisposableTo(disposeBag)
66 |
67 | webView.rx.url
68 | .subscribe(onNext: { url in
69 | self.searchBar.text = url?.absoluteString
70 | print("URL: \(url)")
71 | })
72 | .addDisposableTo(disposeBag)
73 |
74 | webView.rx.estimatedProgress
75 | .subscribe(onNext: {
76 | print("estimatedProgress: \($0)")
77 | })
78 | .addDisposableTo(disposeBag)
79 |
80 | webView.rx.loading
81 | .subscribe(onNext: { loading in
82 | UIApplication.shared.isNetworkActivityIndicatorVisible = loading
83 | print("loading: \(loading)")
84 | })
85 | .addDisposableTo(disposeBag)
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RxSwiftExamples
2 |
3 | [](http://unmaintained.tech/)
4 |
5 | ## Branch master is mostly in Swift 3.0 right now. If you want to see Swift 2.2 version of this repo, please see the [swift-2.2](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/swift-2.2) branch.
6 |
7 | This repo should be a nice starting point for anyone that wants to start the new adventure called FRP with [RxSwift](https://github.com/ReactiveX/RxSwift/).
8 | However, here we also have some references to more advanced examples so that no-one feels unsubscribed 😎
9 |
10 | We try to deeply comment our examples, but bear with us if they aren't and if you have any questions just use the contact information on the bottom of the page and ask away!
11 |
12 | ## Tutorials
13 |
14 | 1. [RxSwift by Examples #1 - The basics](http://www.thedroidsonroids.com/blog/ios/rxswift-by-examples-1-the-basics/). Start your adventure with FRP and RxSwift. This article starts from the basics and shows the example of searching using Rx. [Demo](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxSwiftExample).
15 | 2. [RxSwift by Examples #2 – Observable and the Bind](http://www.thedroidsonroids.com/blog/ios/rxswift-by-examples-2-observable-and-the-bind/). Bindings, subjects, variables and stuff. We are observing and we are observed! [Demo](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Simple%20Apps/ColourfulBall)
16 | 3. [RxSwift by Examples #3 - Networking](http://www.thedroidsonroids.com/blog/ios/rxswift-examples-3-networking/). Networking, Moya, request chaining, optional observers and more!
17 | 4. [RxSwift by Examples #4 - Multithreading](http://www.thedroidsonroids.com/blog/ios/rxswift-examples-4-multithreading/) - `observeOn()`, `subscribeOn()`, `Driver` and more!
18 |
19 | ## Utilites
20 |
21 | 1. [NSObject-Rx](https://github.com/RxSwiftCommunity/NSObject-Rx) - Handy RxSwift extensions on NSObject, including `rx_disposeBag`.
22 | 2. [ObservableArray-RxSwift](https://github.com/safx/ObservableArray-RxSwift) - ObservableArray is an array that can emit messages of elements and diffs on it's changing.
23 | 3. [Cell+Rx](https://github.com/ivanbruel/Cell-Rx) - Handy RxSwift extensions on UITableViewCell and UICollectionViewCell, including rx_reusableDisposeBag.
24 | 3. [RxOptional](https://github.com/RxSwiftCommunity/RxOptional) - RxSwift extentions for Swift optionals and "Occupiable" types.
25 | 4. [RxExt](https://github.com/RxSwiftCommunity/RxSwift-Ext) - Additional operators not found in the core RxSwift distribution.
26 |
27 | ## Extensions to built-in frameworks
28 | 1. [RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources) - Table and Collection View Data Sources for RxSwift. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxDataSourcesExample)
29 | 2. [RxBluetooth](https://github.com/SideEffects-xyz/RxBluetooth) - RxBluetooth is a wrapper library to work with RxSwift and CoreBluetooth.
30 | 3. [RxSegue](https://github.com/RxSwiftCommunity/RxSegue) - Reactive generic segue, implemented with RxSwift.
31 | 4. [RxEasing](https://github.com/lintmachine/RxEasing) - RxSwift-based easing library.
32 | 5. [RxAction](https://github.com/RxSwiftCommunity/Action) - Abstracts actions to be performed in RxSwift. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxActionExample)
33 | 6. [RxWebKit](https://github.com/RxSwiftCommunity/RxWebKit) - RxWebKit is a RxSwift wrapper for WebKit. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxWebKitExample)
34 | 7. [RxMKMapView](https://github.com/RxSwiftCommunity/RxMKMapView) - RxMKMapView is a RxSwift wrapper for MKMapView `delegate`. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxMKMapViewExample)
35 | 8. [RxMediaPicker](https://github.com/RxSwiftCommunity/RxMediaPicker) - A reactive wrapper built around UIImagePickerController.
36 | 9. [RxViewModel](https://github.com/RxSwiftCommunity/RxViewModel) - ReactiveViewModel-esque using RxSwift.
37 | 10. [RxGesture](https://github.com/RxSwiftCommunity/RxGesture) - RxSwfit reactive wrapper for view gestures.
38 | 11. [RxAppState](https://github.com/pixeldock/RxAppState) - RxSwift extensions for UIApplicationDelegate methods to observe changes in your app's state.
39 | 12. [RxBluetoothKit](https://github.com/Polidea/RxBluetoothKit) - iOS Bluetooth library for RxSwift.
40 | 13. [RxMultipeer](https://github.com/RxSwiftCommunity/RxMultipeer) - RxSwift wrapper for MultipeerConnectivity.
41 |
42 | ## Extensions to external frameworks
43 | 1. [RxAlamofire](https://github.com/RxSwiftCommunity/RxAlamofire) - RxSwift wrapper around the elegant HTTP networking in Swift Alamofire. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxAlamofireExample)
44 | 2. [RxRealm](https://github.com/RxSwiftCommunity/RxRealm) - Rx wrapper for Realm's collection types.
45 | 3. [RxNimble](https://github.com/RxSwiftCommunity/RxNimble) - Nimble extensions that making unit testing with RxSwift easier.
46 | 4. [RxQueryKit](https://github.com/QueryKit/RxQueryKit) - RxSwift extensions for dealing with QueryKit.
47 | 5. [FirebaseRxSwiftExtensions](https://github.com/mbalex99/FirebaseRxSwiftExtensions) - Extension Methods for Firebase and RxSwift.
48 | 6. [ReduxKitRxSwift](https://github.com/ReduxKit/ReduxKitRxSwift) - RxSwift bindings for ReduxKit.
49 | 7. [RxHyperdrive](https://github.com/kylef/RxHyperdrive) - RxSwift extensions for Hyperdrive, the generic Swift Web API client.
50 | 8. [RxBrightFutures](https://github.com/SideEffects-xyz/RxBrightFutures) - RxSwift wrapper around the Future/Promise library BrightFutures.
51 | 9. [RxMoya](https://github.com/Moya/Moya/blob/master/docs/RxSwift.md) - RxSwift wrapper for Moya. [Example](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Libraries%20Usage/RxMoyaExample)
52 | 10. [RxSimpleNoSQL](https://github.com/xmartlabs/RxSimpleNoSQL/) - Reactive extensions for SimpleNoSQL.
53 | 11. [RxPermission](https://github.com/sunshinejr/RxPermission) - RxSwift bindings for Permissions API in iOS.
54 |
55 | ## Examples
56 |
57 | 1. [RxChat](https://github.com/bontoJR/RxChat) - Chat application also using RxSwift.
58 | 2. [RxPagination](https://github.com/tryswift/RxPagination) - Really nice demo for "Protocol-Oriented Programming in Networking", using RxSwift.
59 | 3. [RxTestScheduler](https://github.com/kumapo/RxSwiftTestSchedulerExample) - Example of how you can use RxSwift's `TestScheduler`. Unfortunately comments are not in English 😢
60 | 4. [RxGitHubAPI](https://github.com/FengDeng/RxGitHubAPI) - GitHub API example. Unfortunately comments are not in English 😥
61 | 5. [Parse-RxSwift](https://github.com/bluelinelabs/Parse-RxSwift) - A collection of wrapper classes that allow you to use RxSwift Observers in place of Parse's callbacks.
62 | 6. [RxSwiftGram](https://github.com/Dwar3xwar/RxSwiftGram) - Educational App using RxSwift and MVVM with the Instagram API.
63 |
64 | ## Applications
65 |
66 | 1. [Eidolon](https://github.com/artsy/eidolon) - The Artsy Auction Kiosk App.
67 | 2. [Boilerplate](https://github.com/tailec/boilerplate#github-api-client) - GitHub client using MVVM and RxSwift.
68 | 3. [ReactiveWeatherExample](https://github.com/marinbenc/ReactiveWeatherExample) - A simple iOS weather app using the MVVM pattern and RxSwift framework.
69 | 4. [RxMarbles](https://github.com/RxSwiftCommunity/RxMarbles) - RxMarbles iOS app.
70 | 5. [CountItApp](https://github.com/PiXeL16/CountItApp) - Dead simple App with Apple Watch integration that lets you count anything.
71 | 6. [WhatFilm](https://github.com/brocoo/WhatFilm) - Simple iOS app showing popular films, their cast and crew along with images and links to the trailers.
72 |
73 | ## More
74 |
75 | 1. [RxSnippets](https://github.com/RxSwiftCommunity/RxSnippets) - Several snippets for work with RxSwift
76 | 2. [RxSugar](https://github.com/RxSugar/RxSugar) - Simple RxSwift extensions for interacting with Apple APIs.
77 | 3. [ReactiveCommander](https://github.com/pepibumur/ReactiveCommander) - Reactive Command pattern. This one is for RxSwift as well as for ReactiveCocoa.
78 | 4. [CollectionVariable](https://github.com/gitdoapp/CollectionVariable) - RxSwift Variable for collections that report individual changes in the collection.
79 | 5. [RxTwift](https://github.com/mihyaeru21/RxTwift) - A type safe Twitter API client constructed on RxSwift.
80 |
81 | ## Contributing
82 | Feel free to make issues/pull requests if you find something wrong in examples or readme, as well as you can add things you would want to see or you know that are written in RxSwift. Let's make our lives better and help each other!
83 |
84 | ## Author
85 |
86 | Sunshinejr, thesunshinejr@gmail.com, @thesunshinejr
87 |
88 | ## License
89 |
90 | RxSwiftExamples is available under the MIT license. See the LICENSE file for more info.
91 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ColourfulBall
4 | //
5 | // Created by Lukasz Mroz on 19.03.2016.
6 | // Copyright © 2016 Droids On Roids. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | }
43 | ],
44 | "info" : {
45 | "version" : 1,
46 | "author" : "xcode"
47 | }
48 | }
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/CircleViewModel.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CircleViewModel.swift
3 | // ColourfulBall
4 | //
5 | // Created by Lukasz Mroz on 19.03.2016.
6 | // Copyright © 2016 Droids On Roids. All rights reserved.
7 | //
8 |
9 | // This ViewModel is made to extract the logic of creating UIColor based on center of a view.
10 | // Every time new center is produced, we grab it and transform it to specifc UIColor. Then
11 | // ViewController can use it to redraw the view.
12 | //
13 | // If you want to try your Rx skills I'd suggest to add another observable with e.g. width/height that
14 | // the ball could have change based on the center.
15 | //
16 |
17 | import ChameleonFramework
18 | import Foundation
19 | import RxSwift
20 | import RxCocoa
21 |
22 | class CircleViewModel {
23 |
24 | var centerVariable = Variable(.zero) // Create one variable that will be changed and observed
25 | var backgroundColorObservable: Observable! // Create observable that will change backgroundColor based on center
26 | fileprivate let disposeBag = DisposeBag()
27 |
28 | init() {
29 | setup()
30 | }
31 |
32 | func setup() {
33 | // When we get new center, emit new UIColor
34 | backgroundColorObservable = centerVariable.asObservable()
35 | .map { center in
36 | guard let center = center else { return UIColor.flatten(.black)() }
37 |
38 | let red: CGFloat = ((center.x + center.y).truncatingRemainder(dividingBy: 255.0)) / 255.0 // We just manipulate red, but you can do w/e
39 | let green: CGFloat = 0.0
40 | let blue: CGFloat = 0.0
41 |
42 | return UIColor.flatten(UIColor(red: red, green: green, blue: blue, alpha: 1.0))()
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/ColourfulBall/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // ColourfulBall
4 | //
5 | // Created by Lukasz Mroz on 19.03.2016.
6 | // Copyright © 2016 Droids On Roids. All rights reserved.
7 | //
8 | // This example is to show how you can use MVVM (Model-View-ViewModel)
9 | // with Rx and Swift. Since we don't need any of the properties that RxViewModel
10 | // gives, we won't use it in this project. However, if you want more advanced
11 | // usage, I really encourage you to visit RxSwiftCommunity/RxViewModel on github.
12 | //
13 | // In this project we need one ViewModel, which will have logic to our CircleView.
14 | // More on the functionality of the Model in CircleViewModel.swift. Here we observe
15 | // when the color of circle should be changed (by subscribing to the observable
16 | // in CircleViewModel, and based on the color given, we change the color of the
17 | // CircleView and use the complementary color for the background view given by
18 | // Chameleon. To achieve that we need to bind the center of the CircleView frame
19 | // to centerObservable in CircleViewModel. It will then handle the rest.
20 |
21 | import ChameleonFramework
22 | import UIKit
23 | import RxSwift
24 | import RxCocoa
25 |
26 | class ViewController: UIViewController {
27 |
28 | var circleView: UIView!
29 | fileprivate var circleViewModel: CircleViewModel!
30 | fileprivate let disposeBag = DisposeBag()
31 |
32 | override func viewDidLoad() {
33 | super.viewDidLoad()
34 | setup()
35 | }
36 |
37 | func setup() {
38 | // Add circle view
39 | circleView = UIView(frame: CGRect(origin: view.center, size: CGSize(width: 100.0, height: 100.0)))
40 | circleView.layer.cornerRadius = circleView.frame.width / 2.0
41 | circleView.center = view.center
42 | circleView.backgroundColor = .green
43 | view.addSubview(circleView)
44 |
45 | circleViewModel = CircleViewModel()
46 | // Bind the center point of the CircleView to the centerObservable
47 | circleView
48 | .rx.observe(CGPoint.self, "center")
49 | .bindTo(circleViewModel.centerVariable)
50 | .addDisposableTo(disposeBag)
51 |
52 | // Subscribe to backgroundObservable to get new colors from the ViewModel.
53 | circleViewModel.backgroundColorObservable
54 | .subscribe(onNext:{ [weak self] backgroundColor in
55 | UIView.animate(withDuration: 0.1) {
56 | self?.circleView.backgroundColor = backgroundColor
57 | // Try to get complementary color for given background color
58 | let viewBackgroundColor = UIColor(complementaryFlatColorOf: backgroundColor)
59 | // If it is different that the color
60 | if viewBackgroundColor != backgroundColor {
61 | // Assign it as a background color of the view
62 | // We only want different color to be able to see that circle in a view
63 | self?.view.backgroundColor = viewBackgroundColor
64 | }
65 | }
66 | })
67 | .addDisposableTo(disposeBag)
68 |
69 | let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(circleMoved(_:)))
70 | circleView.addGestureRecognizer(gestureRecognizer)
71 | }
72 |
73 | func circleMoved(_ recognizer: UIPanGestureRecognizer) {
74 | let location = recognizer.location(in: view)
75 | UIView.animate(withDuration: 0.1) {
76 | self.circleView.center = location
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 | use_frameworks!
3 |
4 | target 'ColourfulBall' do
5 |
6 | pod 'RxSwift'
7 | pod 'RxCocoa'
8 | pod 'ChameleonFramework/Swift', :git => 'https://github.com/ViccAlexander/Chameleon.git'
9 |
10 | end
11 |
12 | post_install do |installer|
13 | installer.pods_project.targets.each do |target|
14 | target.build_configurations.each do |config|
15 | config.build_settings['ENABLE_TESTABILITY'] = 'YES'
16 | config.build_settings['SWIFT_VERSION'] = '3.0'
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/Simple Apps/ColourfulBall/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - ChameleonFramework/Default (2.1.0)
3 | - ChameleonFramework/Swift (2.1.0):
4 | - ChameleonFramework/Default
5 | - RxCocoa (3.0.1):
6 | - RxSwift (~> 3.0)
7 | - RxSwift (3.0.1)
8 |
9 | DEPENDENCIES:
10 | - ChameleonFramework/Swift (from `https://github.com/ViccAlexander/Chameleon.git`)
11 | - RxCocoa
12 | - RxSwift
13 |
14 | EXTERNAL SOURCES:
15 | ChameleonFramework:
16 | :git: https://github.com/ViccAlexander/Chameleon.git
17 |
18 | CHECKOUT OPTIONS:
19 | ChameleonFramework:
20 | :commit: dcf98f9bf3a632a7f40679b7da46f09681e48526
21 | :git: https://github.com/ViccAlexander/Chameleon.git
22 |
23 | SPEC CHECKSUMS:
24 | ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64
25 | RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
26 | RxSwift: af5680055c4ad04480189c52d28385b1029493a6
27 |
28 | PODFILE CHECKSUM: 2604a997ac0bf63110c916e02e9252ca4c1a7c04
29 |
30 | COCOAPODS: 1.1.1
31 |
--------------------------------------------------------------------------------
/Simple Apps/README.md:
--------------------------------------------------------------------------------
1 | ## List of examples
2 | - [ColourfulBall](https://github.com/DroidsOnRoids/RxSwiftExamples/tree/master/Simple%20Apps/ColourfulBall) - this is example of using MVVM and animations with RxSwift. Bindings and stuff. Previously RxViewModelExample.
3 |
4 | ## TODO
5 | --
6 |
7 | ## Author
8 |
9 | Sunshinejr, thesunshinejr@gmail.com, @thesunshinejr
10 |
11 | ## License
12 |
13 | RxSwiftExamples is available under the MIT license. See the LICENSE file for more info.
14 |
--------------------------------------------------------------------------------