From b11faa1228c8054dcfdb21b336ea73b8ba8ec5c4 Mon Sep 17 00:00:00 2001 From: Tigran Hambardzumyan Date: Fri, 20 Apr 2018 19:09:33 +0400 Subject: [PATCH 1/4] Adding allowNil method --- STDevRxExt/Classes/FilterExtensions.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/STDevRxExt/Classes/FilterExtensions.swift b/STDevRxExt/Classes/FilterExtensions.swift index 28c380e..ddf21d0 100644 --- a/STDevRxExt/Classes/FilterExtensions.swift +++ b/STDevRxExt/Classes/FilterExtensions.swift @@ -57,6 +57,14 @@ public extension ObservableType { } +public extension ObservableType where E == Optional { + + public func allowNil() -> Observable { + return filter { $0 == nil } + } + +} + public extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy, E == Bool { public func allowTrue() -> Driver { From 966b3ac00d142226d56ecf90324da0b185aaaf0e Mon Sep 17 00:00:00 2001 From: Tigran Hambardzumyan Date: Fri, 20 Apr 2018 19:10:18 +0400 Subject: [PATCH 2/4] Adding allowNil function example Replacing all prints with dump --- Example/Example.playground/Contents.swift | 45 ++++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/Example/Example.playground/Contents.swift b/Example/Example.playground/Contents.swift index 503ff3f..55198e1 100644 --- a/Example/Example.playground/Contents.swift +++ b/Example/Example.playground/Contents.swift @@ -23,7 +23,7 @@ example("allowTrue") { Observable.of(true, false, false, true, true) .allowTrue() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -34,7 +34,7 @@ example("allowTrue Optional") { Observable.of(true, false, nil, true, nil, true) .allowTrue() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -45,7 +45,7 @@ example("allowFalse") { Observable.of(true, false, false, true, false) .allowFalse() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -56,7 +56,7 @@ example("allowFalse Optional") { Observable.of(true, false, nil, true, nil, true, false) .allowFalse() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -66,7 +66,7 @@ example("allowTrueOrNil") { Observable.of(true, false, nil, true, nil, true, false) .allowTrueOrNil() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -76,9 +76,9 @@ example("allowFalseOrNil") { Observable.of(true, false, nil, true, nil, true, false) .allowFalseOrNil() - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) - + } example("filterIfNil") { @@ -91,14 +91,14 @@ example("filterIfNil") { subject .filterIfNil(optional) - .subscribe(onNext: { print("Subscription1 --> \($0)") }) + .subscribe(onNext: { dump($0, name: "Subscription1") }) .disposed(by: disposeBag) optional = "enable" subject .filterIfNil(optional) - .subscribe(onNext: { print("Subscription2 --> \($0)") }) + .subscribe(onNext: { dump($0, name: "Subscription2") }) .disposed(by: disposeBag) subject.onNext("🐹") @@ -116,14 +116,14 @@ example("filterIfNotNil") { subject .filterIfNotNil(optional) - .subscribe(onNext: { print("Subscription1 --> \($0)") }) + .subscribe(onNext: { dump($0, name: "Subscription1") }) .disposed(by: disposeBag) optional = "enable" subject .filterIfNotNil(optional) - .subscribe(onNext: { print("Subscription2 --> \($0)") }) + .subscribe(onNext: { dump($0, name: "Subscription2") }) .disposed(by: disposeBag) subject.onNext("🐹") @@ -131,9 +131,18 @@ example("filterIfNotNil") { subject.onNext("🐭") } +example("Allow nil") { + let disposeBag = DisposeBag() + + Observable.of(true, false, nil, true, nil, true, false) + .allowNil() + .subscribe(onNext: { dump($0) }) + .disposed(by: disposeBag) +} + /*: ## Map Extensions - */ +*/ example("map(to:)") { @@ -141,7 +150,7 @@ example("map(to:)") { Observable.of(1, 5, 7, 8) .map(to: "ping") - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0 as String) }) .disposed(by: disposeBag) } @@ -158,26 +167,26 @@ example("map(at:)") { observable .map(at: \.title) - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) observable .map(at: \.author.firstName) - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } /*: ## Cast Extensions - */ +*/ example("cast(to:)") { let disposeBag = DisposeBag() Observable.of("1", "5", "7", "8") .cast(to: String.self) - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } @@ -187,7 +196,7 @@ example("forceCast(to:)") { Observable.of("1", "5", "7", "8") .forceCast(to: String.self) - .subscribe(onNext: { print($0) }) + .subscribe(onNext: { dump($0) }) .disposed(by: disposeBag) } From afc51421f5d5426c1c18aa95efc4f6b4ec0fd026 Mon Sep 17 00:00:00 2001 From: Tigran Hambardzumyan Date: Fri, 20 Apr 2018 19:10:47 +0400 Subject: [PATCH 3/4] Upgrade to Xcode 9.3 --- Example/Podfile.lock | 8 ++-- Example/STDevRxExt.xcodeproj/project.pbxproj | 38 ++++++++++--------- .../xcschemes/STDevRxExt-Example.xcscheme | 4 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ 4 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 Example/STDevRxExt.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 8275d09..59c20d7 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - RxCocoa (4.1.2): - RxSwift (~> 4.0) - RxSwift (4.1.2) - - STDevRxExt (0.1.0): + - STDevRxExt (0.1.1): - RxCocoa (~> 4.1.2) - RxSwift (~> 4.1.2) @@ -16,8 +16,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a RxSwift: e49536837d9901277638493ea537394d4b55f570 - STDevRxExt: 523757c19d070f1183ed46f3c262671e3f549467 + STDevRxExt: db625d87a2f2f74ce2f9efb869b020e944781851 -PODFILE CHECKSUM: f42840d4bfdb7c3c06cec77f4e686adfdc3604f1 +PODFILE CHECKSUM: 03f0d9ab6a3ddca86ac78ea53d2cfc1bef03c8f8 -COCOAPODS: 1.4.0 +COCOAPODS: 1.3.1 diff --git a/Example/STDevRxExt.xcodeproj/project.pbxproj b/Example/STDevRxExt.xcodeproj/project.pbxproj index 7dbda9b..56f22d3 100644 --- a/Example/STDevRxExt.xcodeproj/project.pbxproj +++ b/Example/STDevRxExt.xcodeproj/project.pbxproj @@ -112,7 +112,7 @@ 607FACE21AFB9204008FA782 /* Frameworks */, 607FACE31AFB9204008FA782 /* Resources */, ABFFA786528145F941134D7B /* [CP] Embed Pods Frameworks */, - CCB8043419D447B3CFB8B185 /* [CP] Copy Pods Resources */, + 1314E7A7F724A441011AC3F2 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -130,7 +130,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACE41AFB9204008FA782 = { @@ -169,6 +169,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1314E7A7F724A441011AC3F2 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-STDevRxExt_Tests/Pods-STDevRxExt_Tests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; A3707137EA0E0FF550D3D5D1 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -209,21 +224,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-STDevRxExt_Tests/Pods-STDevRxExt_Tests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - CCB8043419D447B3CFB8B185 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-STDevRxExt_Tests/Pods-STDevRxExt_Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -250,12 +250,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -303,12 +305,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/Example/STDevRxExt.xcodeproj/xcshareddata/xcschemes/STDevRxExt-Example.xcscheme b/Example/STDevRxExt.xcodeproj/xcshareddata/xcschemes/STDevRxExt-Example.xcscheme index 8f77f7d..fa288b0 100644 --- a/Example/STDevRxExt.xcodeproj/xcshareddata/xcschemes/STDevRxExt-Example.xcscheme +++ b/Example/STDevRxExt.xcodeproj/xcshareddata/xcschemes/STDevRxExt-Example.xcscheme @@ -1,6 +1,6 @@ + + + + IDEDidComputeMac32BitWarning + + + From 4c6c2ffb0599521264a526f808e54aee00d511e0 Mon Sep 17 00:00:00 2001 From: Tigran Hambardzumyan Date: Fri, 20 Apr 2018 19:23:55 +0400 Subject: [PATCH 4/4] Bumped version number to 0.1.2 --- STDevRxExt.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STDevRxExt.podspec b/STDevRxExt.podspec index 8f76c48..c74ef11 100644 --- a/STDevRxExt.podspec +++ b/STDevRxExt.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'STDevRxExt' - s.version = '0.1.1' + s.version = '0.1.2' s.summary = 'STDevRxExt contains some extension functions for RxSwift and RxCoca which makes our live easy.' s.description = <<-DESC