From 7cb5a3b79ab675ab9a9d5059bf99a6e2b8af9a37 Mon Sep 17 00:00:00 2001 From: Tom Burns Date: Wed, 24 Feb 2016 20:47:13 -0600 Subject: [PATCH 01/21] Make name parameter of rx_notification optional. --- RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift b/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift index 0f912e36..a9ad4517 100644 --- a/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift +++ b/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift @@ -20,7 +20,7 @@ extension NSNotificationCenter { - returns: Observable sequence of posted notifications. */ @warn_unused_result(message="http://git.io/rxs.uo") - public func rx_notification(name: String, object: AnyObject? = nil) -> Observable { + public func rx_notification(name: String?, object: AnyObject? = nil) -> Observable { return Observable.create { [weak object] observer in let nsObserver = self.addObserverForName(name, object: object, queue: nil) { notification in observer.on(.Next(notification)) From fffd955fbaf7bc14811acf00ed4d7df716029cd2 Mon Sep 17 00:00:00 2001 From: Joanna Kubiak Date: Sat, 27 Feb 2016 17:14:33 +0100 Subject: [PATCH 02/21] Issue #511 - added free to reslove memory leaking warnings --- RxCocoa/Common/_RXDelegateProxy.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RxCocoa/Common/_RXDelegateProxy.m b/RxCocoa/Common/_RXDelegateProxy.m index 03595af6..581fbabb 100644 --- a/RxCocoa/Common/_RXDelegateProxy.m +++ b/RxCocoa/Common/_RXDelegateProxy.m @@ -41,6 +41,8 @@ static NSMutableDictionary *forwardableSelectorsPerClass = nil; for (unsigned int i = 0; i < numberOfBaseProtocols; ++i) { [selectors unionSet:[self collectSelectorsForProtocol:pSubprotocols[i]]]; } + + free(pSubprotocols); return selectors; } From 8559a67d898cde5472d737f2bd80ecaaa76051e1 Mon Sep 17 00:00:00 2001 From: sambae Date: Sat, 27 Feb 2016 18:48:16 -0500 Subject: [PATCH 03/21] Adds `rx_progress` to `UIProgressView` --- Rx.xcodeproj/project.pbxproj | 6 ++++ RxCocoa/iOS/UIProgressView+Rx.swift | 30 +++++++++++++++++++ .../RxCocoaTests/Control+RxTests+UIKit.swift | 17 +++++++++++ 3 files changed, 53 insertions(+) create mode 100644 RxCocoa/iOS/UIProgressView+Rx.swift diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index 594d9c37..41c88143 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 9BA1CBFD1C0F84A10044B50A /* UIActivityIndicatorView+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BA1CBD11C0F7C0A0044B50A /* UIActivityIndicatorView+Rx.swift */; }; 9BA1CBFE1C0F84C40044B50A /* UIActivityIndicatorView+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BA1CBD11C0F7C0A0044B50A /* UIActivityIndicatorView+Rx.swift */; }; 9D71C4D21BF08191006E8F59 /* UIButton+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88254061B8A752B00B02D69 /* UIButton+Rx.swift */; }; + AAE623761C82475700FC7801 /* UIProgressView+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE623751C82475700FC7801 /* UIProgressView+Rx.swift */; }; + AAE623771C82475700FC7801 /* UIProgressView+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE623751C82475700FC7801 /* UIProgressView+Rx.swift */; }; B1B7C3BD1BDD39DB0076934E /* TakeLast.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1B7C3BC1BDD39DB0076934E /* TakeLast.swift */; }; B1B7C3BE1BDD39DB0076934E /* TakeLast.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1B7C3BC1BDD39DB0076934E /* TakeLast.swift */; }; B1B7C3BF1BDD39DB0076934E /* TakeLast.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1B7C3BC1BDD39DB0076934E /* TakeLast.swift */; }; @@ -1325,6 +1327,7 @@ 84C225A21C33F00B008724EC /* RxTextStorageDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTextStorageDelegateProxy.swift; sourceTree = ""; }; 9BA1CBD11C0F7C0A0044B50A /* UIActivityIndicatorView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIActivityIndicatorView+Rx.swift"; sourceTree = ""; }; A111CE961B91C97C00D0DCEE /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AAE623751C82475700FC7801 /* UIProgressView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIProgressView+Rx.swift"; sourceTree = ""; }; B1B7C3BC1BDD39DB0076934E /* TakeLast.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TakeLast.swift; sourceTree = ""; }; B1D8998E1BF653410027B05C /* Timeout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Timeout.swift; sourceTree = ""; }; C807F3611C2ACED300017910 /* TestSchedulerVirtualTimeConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestSchedulerVirtualTimeConverter.swift; sourceTree = ""; }; @@ -2322,6 +2325,7 @@ C882540A1B8A752B00B02D69 /* UIGestureRecognizer+Rx.swift */, C882540B1B8A752B00B02D69 /* UIImageView+Rx.swift */, C882540C1B8A752B00B02D69 /* UILabel+Rx.swift */, + AAE623751C82475700FC7801 /* UIProgressView+Rx.swift */, 7F600F3D1C5D0C0100535B1D /* UIRefreshControl+Rx.swift */, C882540D1B8A752B00B02D69 /* UIScrollView+Rx.swift */, C882540E1B8A752B00B02D69 /* UISearchBar+Rx.swift */, @@ -3251,6 +3255,7 @@ C80D338F1B91EF9E0014629D /* Observable+Bind.swift in Sources */, C88254311B8A752B00B02D69 /* UISegmentedControl+Rx.swift in Sources */, C8093EED1B8A732E0088E94D /* KVOObservable.swift in Sources */, + AAE623761C82475700FC7801 /* UIProgressView+Rx.swift in Sources */, C8DB968D1BF7595D0084BD53 /* KVORepresentable+Swift.swift in Sources */, C80DDEB11BCE8CA3006A1832 /* Driver+Operators+arity.swift in Sources */, C88254281B8A752B00B02D69 /* UIButton+Rx.swift in Sources */, @@ -4248,6 +4253,7 @@ D203C50D1BB9C53E00D02D00 /* UISegmentedControl+Rx.swift in Sources */, C8C4B4C41C17727000828BD5 /* MessageSentObserver.swift in Sources */, D2138C861BB9BEBE00339B5C /* Observable+Bind.swift in Sources */, + AAE623771C82475700FC7801 /* UIProgressView+Rx.swift in Sources */, D203C50A1BB9C53E00D02D00 /* UILabel+Rx.swift in Sources */, D203C4F51BB9C52900D02D00 /* ItemEvents.swift in Sources */, C8BCD3F61C14B6D1005F1280 /* NSLayoutConstraint+Rx.swift in Sources */, diff --git a/RxCocoa/iOS/UIProgressView+Rx.swift b/RxCocoa/iOS/UIProgressView+Rx.swift new file mode 100644 index 00000000..3b59dd71 --- /dev/null +++ b/RxCocoa/iOS/UIProgressView+Rx.swift @@ -0,0 +1,30 @@ +// +// UIProgressView+Rx.swift +// Rx +// +// Created by Samuel Bae on 2/27/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension UIProgressView { + + /** + Bindable sink for `progress` property + */ + public var rx_progress: AnyObserver { + return UIBindingObserver(UIElement: self) { progressView, progress in + progressView.progress = progress + }.asObserver() + } + +} + +#endif \ No newline at end of file diff --git a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift index f604df86..cc6923e2 100644 --- a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift +++ b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift @@ -287,6 +287,23 @@ extension ControlTests { } } +// UIProgressView +extension ControlTests { + func testProgressView_HasWeakReference() { + ensureControlObserverHasWeakReference(UIProgressView(), { (progressView: UIProgressView) -> AnyObserver in progressView.rx_progress }, { Variable(0.0).asObservable() }) + } + + func testProgressView_NextElementsSetsValue() { + let subject = UIProgressView() + let progressSequence = Variable(0.0) + let disposable = progressSequence.asObservable().bindTo(subject.rx_progress) + defer { disposable.dispose() } + + progressSequence.value = 1.0 + XCTAssert(subject.progress == progressSequence.value, "Expected progress to have been set") + } +} + // UITableView extension ControlTests { func testTableView_DelegateEventCompletesOnDealloc() { From 8b9bbff4ee5f89b4972eea261cff86e6ef5f16ec Mon Sep 17 00:00:00 2001 From: Mateusz Derks Date: Fri, 4 Mar 2016 14:05:28 +0100 Subject: [PATCH 04/21] Adds 'rx_badgeValue' to UITabBarItem --- Documentation/API.md | 8 +++++ Rx.xcodeproj/project.pbxproj | 14 ++++++++ RxCocoa/iOS/UITabBarItem+Rx.swift | 30 +++++++++++++++++ Tests/RxCocoaTests/UITabBarItem+RxTests.swift | 33 +++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 RxCocoa/iOS/UITabBarItem+Rx.swift create mode 100644 Tests/RxCocoaTests/UITabBarItem+RxTests.swift diff --git a/Documentation/API.md b/Documentation/API.md index 32651338..74d11aae 100644 --- a/Documentation/API.md +++ b/Documentation/API.md @@ -455,3 +455,11 @@ extension NSTextField { } ``` + +```swift +extension UITabBarItem { + + public var rx_badgeValue: AnyObserver {} + +} +``` diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index 41c88143..4f76e921 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -11,6 +11,11 @@ 79E9DE8A1C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; 79E9DE8B1C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; 79E9DE8C1C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; + 7EDBAEB41C89B1A6006CBE67 /* UITabBarItem+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDBAEAB1C89B1A5006CBE67 /* UITabBarItem+RxTests.swift */; }; + 7EDBAEBC1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */; }; + 7EDBAEBE1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */; }; + 7EDBAEBF1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */; }; + 7EDBAEC31C89BCB9006CBE67 /* UITabBarItem+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDBAEAB1C89B1A5006CBE67 /* UITabBarItem+RxTests.swift */; }; 7F600F3F1C5D0C6C00535B1D /* UIRefreshControl+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F600F3D1C5D0C0100535B1D /* UIRefreshControl+Rx.swift */; }; 7F600F401C5D0C6D00535B1D /* UIRefreshControl+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F600F3D1C5D0C0100535B1D /* UIRefreshControl+Rx.swift */; }; 7F600F411C5D0C6E00535B1D /* UIRefreshControl+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F600F3D1C5D0C0100535B1D /* UIRefreshControl+Rx.swift */; }; @@ -1318,6 +1323,8 @@ /* Begin PBXFileReference section */ 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchQueueSchedulerQOS.swift; sourceTree = ""; }; + 7EDBAEAB1C89B1A5006CBE67 /* UITabBarItem+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITabBarItem+RxTests.swift"; sourceTree = ""; }; + 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITabBarItem+Rx.swift"; sourceTree = ""; }; 7F600F3D1C5D0C0100535B1D /* UIRefreshControl+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIRefreshControl+Rx.swift"; sourceTree = ""; }; 7F600F421C5D0D2D00535B1D /* UIRefreshControl+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIRefreshControl+RxTests.swift"; sourceTree = ""; }; 842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextStorage+Rx.swift"; sourceTree = ""; }; @@ -2203,6 +2210,7 @@ C83508F01C38706D0027C24C /* SentMessageTest.swift */, C83508F11C38706D0027C24C /* UIView+RxTests.swift */, 7F600F421C5D0D2D00535B1D /* UIRefreshControl+RxTests.swift */, + 7EDBAEAB1C89B1A5006CBE67 /* UITabBarItem+RxTests.swift */, ); path = RxCocoaTests; sourceTree = ""; @@ -2340,6 +2348,7 @@ 9BA1CBD11C0F7C0A0044B50A /* UIActivityIndicatorView+Rx.swift */, 8479BC4A1C3ACED100FB8B54 /* UIImagePickerController+Rx.swift */, C8BCD3EC1C14B5FB005F1280 /* UIView+Rx.swift */, + 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */, ); path = iOS; sourceTree = ""; @@ -3248,6 +3257,7 @@ C882542E1B8A752B00B02D69 /* UILabel+Rx.swift in Sources */, C88254211B8A752B00B02D69 /* RxSearchBarDelegateProxy.swift in Sources */, C80DDEA71BCE69BA006A1832 /* ObservableConvertibleType+Driver.swift in Sources */, + 7EDBAEBC1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */, C839365F1C70E02200A9A09E /* UIApplication+Rx.swift in Sources */, C80DDE9F1BCE69BA006A1832 /* Driver+Subscription.swift in Sources */, C811C89D1C24D80100A2DDD4 /* DeallocObservable.swift in Sources */, @@ -3401,6 +3411,7 @@ C83509331C38706E0027C24C /* Driver+Extensions.swift in Sources */, C835094F1C38706E0027C24C /* CurrentThreadSchedulerTest.swift in Sources */, C835093E1C38706E0027C24C /* UIView+RxTests.swift in Sources */, + 7EDBAEB41C89B1A6006CBE67 /* UITabBarItem+RxTests.swift in Sources */, C83509411C38706E0027C24C /* BackgroundThreadPrimitiveHotObservable.swift in Sources */, C83509581C38706E0027C24C /* Observable+MultipleTest+CombineLatest.swift in Sources */, C83509651C38706E0027C24C /* VirtualSchedulerTest.swift in Sources */, @@ -3486,6 +3497,7 @@ C8350A121C38756A0027C24C /* Observable+StandardSequenceOperatorsTest.swift in Sources */, C83509C31C3875220027C24C /* KVOObservableTests.swift in Sources */, C83509F91C38755D0027C24C /* MainSchedulerTests.swift in Sources */, + 7EDBAEC31C89BCB9006CBE67 /* UITabBarItem+RxTests.swift in Sources */, C83509AB1C3874D20027C24C /* XCTest+AllTests.swift in Sources */, C83509C11C3875220027C24C /* Driver+Extensions.swift in Sources */, C83509DD1C38754C0027C24C /* EquatableArray.swift in Sources */, @@ -4178,6 +4190,7 @@ C8F0C03A1BBBFBB9001B112F /* ControlTarget.swift in Sources */, C8F0C03B1BBBFBB9001B112F /* UISearchBar+Rx.swift in Sources */, C8F0C03C1BBBFBB9001B112F /* ItemEvents.swift in Sources */, + 7EDBAEBF1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */, C8DB968B1BF756F40084BD53 /* KVORepresentable+CoreGraphics.swift in Sources */, C8FD21B11C67E14C00863EC3 /* UIBindingObserver.swift in Sources */, C8F0C03D1BBBFBB9001B112F /* RxTableViewDataSourceType.swift in Sources */, @@ -4271,6 +4284,7 @@ 9D71C4D21BF08191006E8F59 /* UIButton+Rx.swift in Sources */, D203C4FD1BB9C53700D02D00 /* RxSearchBarDelegateProxy.swift in Sources */, D2138C8A1BB9BEBE00339B5C /* Logging.swift in Sources */, + 7EDBAEBE1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */, C8DB968A1BF756F40084BD53 /* KVORepresentable+CoreGraphics.swift in Sources */, C8FD21B01C67E14C00863EC3 /* UIBindingObserver.swift in Sources */, D203C50F1BB9C53E00D02D00 /* UIStepper+Rx.swift in Sources */, diff --git a/RxCocoa/iOS/UITabBarItem+Rx.swift b/RxCocoa/iOS/UITabBarItem+Rx.swift new file mode 100644 index 00000000..203a2c6e --- /dev/null +++ b/RxCocoa/iOS/UITabBarItem+Rx.swift @@ -0,0 +1,30 @@ +// +// UITabBarItem+Rx.swift +// Rx +// +// Created by Mateusz Derks on 04/03/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + + import Foundation + import UIKit +#if !RX_NO_MODULE + import RxSwift +#endif + +extension UITabBarItem { + + /** + Bindable sink for `hidden` property. + */ + public var rx_badgeValue: AnyObserver { + return UIBindingObserver(UIElement: self) { tabBarItem, badgeValue in + tabBarItem.badgeValue = badgeValue + }.asObserver() + } + +} + +#endif diff --git a/Tests/RxCocoaTests/UITabBarItem+RxTests.swift b/Tests/RxCocoaTests/UITabBarItem+RxTests.swift new file mode 100644 index 00000000..b3a2165d --- /dev/null +++ b/Tests/RxCocoaTests/UITabBarItem+RxTests.swift @@ -0,0 +1,33 @@ +// +// UITabBarItem+RxTests.swift +// Rx +// +// Created by Mateusz Derks on 04/03/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +import RxSwift +import RxCocoa +import UIKit +import XCTest + +class UITabBarItemTests : RxTest { +} + +extension UITabBarItemTests { + func testBadgetValue_Text() { + let subject = UITabBarItem(tabBarSystemItem: .More, tag: 0) + Observable.just("5").subscribe(subject.rx_badgeValue).dispose() + + XCTAssertTrue(subject.badgeValue == "5") + } + + func testBadgetValue_Empty() { + let subject = UITabBarItem(tabBarSystemItem: .More, tag: 0) + Observable.just(nil).subscribe(subject.rx_badgeValue).dispose() + + XCTAssertTrue(subject.badgeValue == nil) + } +} From a7508fb3a755d172c6e6d2ce1eeaf4dee123de64 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sat, 5 Mar 2016 19:37:57 +0100 Subject: [PATCH 05/21] Fixes `README.md` examples. --- Documentation/Examples.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/Examples.md b/Documentation/Examples.md index ae81a65b..78950266 100644 --- a/Documentation/Examples.md +++ b/Documentation/Examples.md @@ -46,7 +46,9 @@ let b /*: Observable*/ = Variable(2) // b = 2 // if a + b >= 0 { // c = "\(a + b) is positive" // } -let c = Observable.combineLatest(a, b) { $0 + $1 } // combines latest values of variables `a` and `b` using `+` + + // combines latest values of variables `a` and `b` using `+` +let c = Observable.combineLatest(a.asObservable(), b.asObservable()) { $0 + $1 } .filter { $0 >= 0 } // if `a + b >= 0` is true, `a + b` is passed to map operator .map { "\($0) is positive" } // maps `a + b` to "\(a + b) is positive" From 375121f8e7934578d5c3ce31def061c348183fe8 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sat, 5 Mar 2016 21:03:16 +0100 Subject: [PATCH 06/21] Fixes using original image instead of edited image. #492 --- .../RxExample/Examples/ImagePicker/ImagePickerController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RxExample/RxExample/Examples/ImagePicker/ImagePickerController.swift b/RxExample/RxExample/Examples/ImagePicker/ImagePickerController.swift index 3dd568d2..0f247051 100644 --- a/RxExample/RxExample/Examples/ImagePicker/ImagePickerController.swift +++ b/RxExample/RxExample/Examples/ImagePicker/ImagePickerController.swift @@ -68,7 +68,7 @@ class ImagePickerController: ViewController { .take(1) } .map { info in - return info[UIImagePickerControllerOriginalImage] as? UIImage + return info[UIImagePickerControllerEditedImage] as? UIImage } .bindTo(imageView.rx_image) .addDisposableTo(disposeBag) From 18acdd02ffd7408b96a069276c95f8924338e205 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sat, 5 Mar 2016 21:04:06 +0100 Subject: [PATCH 07/21] Fixes `rx_badgeValue` inline documentation. --- RxCocoa/iOS/UITabBarItem+Rx.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RxCocoa/iOS/UITabBarItem+Rx.swift b/RxCocoa/iOS/UITabBarItem+Rx.swift index 203a2c6e..2d07cde4 100644 --- a/RxCocoa/iOS/UITabBarItem+Rx.swift +++ b/RxCocoa/iOS/UITabBarItem+Rx.swift @@ -17,7 +17,7 @@ extension UITabBarItem { /** - Bindable sink for `hidden` property. + Bindable sink for `badgeValue` property. */ public var rx_badgeValue: AnyObserver { return UIBindingObserver(UIElement: self) { tabBarItem, badgeValue in From dbb2261f678c211e8de328e04f95d4186dc51f92 Mon Sep 17 00:00:00 2001 From: Afonso Date: Sat, 5 Mar 2016 21:44:49 +0000 Subject: [PATCH 08/21] Fixed Grammar mistake then/than "Then" was being used as the comparison connector of some sentences. The correct word usage is "than" --- Documentation/GettingStarted.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/GettingStarted.md b/Documentation/GettingStarted.md index 0abc561a..c6039b2f 100644 --- a/Documentation/GettingStarted.md +++ b/Documentation/GettingStarted.md @@ -481,7 +481,7 @@ Disposed Ended ---- ``` -**Every subscriber upon subscription usually generates it's own separate sequence of elements. Operators are stateless by default. There is vastly more stateless operators then stateful ones.** +**Every subscriber upon subscription usually generates it's own separate sequence of elements. Operators are stateless by default. There are vastly more stateless operators than stateful ones.** ## Sharing subscription and `shareReplay` operator @@ -964,7 +964,7 @@ self.rx_observe(CGRect.self, "view.frame", retainSelf: false) ### `rx_observeWeakly` -`rx_observeWeakly` has somewhat slower then `rx_observe` because it has to handle object deallocation in case of weak references. +`rx_observeWeakly` has somewhat slower than `rx_observe` because it has to handle object deallocation in case of weak references. It can be used in all cases where `rx_observe` can be used and additionally From 6e08500ebc25145c6d531022985c3039b408dbb0 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 6 Mar 2016 22:07:58 +0100 Subject: [PATCH 09/21] Improves single operator logic. --- .../Implementations/SingleAsync.swift | 2 +- Sources/AllTests/main.swift | 2 ++ ...servable+StandardSequenceOperatorsTest.swift | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/RxSwift/Observables/Implementations/SingleAsync.swift b/RxSwift/Observables/Implementations/SingleAsync.swift index 38938144..af7a09ae 100644 --- a/RxSwift/Observables/Implementations/SingleAsync.swift +++ b/RxSwift/Observables/Implementations/SingleAsync.swift @@ -36,8 +36,8 @@ class SingleAsyncSink : S } if _seenValue == false { - forwardOn(.Next(value)) _seenValue = true + forwardOn(.Next(value)) } else { forwardOn(.Error(RxError.MoreThanOneElement)) dispose() diff --git a/Sources/AllTests/main.swift b/Sources/AllTests/main.swift index 7caa7139..d9e262f0 100644 --- a/Sources/AllTests/main.swift +++ b/Sources/AllTests/main.swift @@ -468,11 +468,13 @@ _ObservableStandardSequenceOperatorsTest.allTests = [ ("testSingle_One", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSingle_One(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), ("testSingle_Many", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSingle_Many(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), //("testSingle_Error", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSingle_Error(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), + ("testSingle_DecrementCountsFirst", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSingle_DecrementCountsFirst(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), ("testSinglePredicate_Empty", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_Empty(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), ("testSinglePredicate_One", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_One(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), ("testSinglePredicate_Many", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_Many(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), //("testSinglePredicate_Error", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_Error(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), //("testSinglePredicate_Throws", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_Throws(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), + ("testSinglePredicate_DecrementCountsFirst", { _ObservableStandardSequenceOperatorsTest.setUp(); _ObservableStandardSequenceOperatorsTest.testSinglePredicate_DecrementCountsFirst(); _ObservableStandardSequenceOperatorsTest.tearDown(); }), ] diff --git a/Tests/RxSwiftTests/Tests/Observable+StandardSequenceOperatorsTest.swift b/Tests/RxSwiftTests/Tests/Observable+StandardSequenceOperatorsTest.swift index 7dcf86ad..31f0858d 100644 --- a/Tests/RxSwiftTests/Tests/Observable+StandardSequenceOperatorsTest.swift +++ b/Tests/RxSwiftTests/Tests/Observable+StandardSequenceOperatorsTest.swift @@ -5067,6 +5067,14 @@ extension ObservableStandardSequenceOperatorsTest { Subscription(200, 210) ]) } + + func testSingle_DecrementCountsFirst() { + let k = BehaviorSubject(value: false) + + _ = k.single { _ in true }.subscribeNext { n in + k.on(.Next(!n)) + } + } func testSinglePredicate_Empty() { let scheduler = TestScheduler(initialClock: 0) @@ -5199,5 +5207,14 @@ extension ObservableStandardSequenceOperatorsTest { Subscription(200, 230) ]) } + + func testSinglePredicate_DecrementCountsFirst() { + let k = BehaviorSubject(value: false) + + _ = k.single { _ in true }.subscribeNext { n in + k.on(.Next(!n)) + } + + } } From c8aa48f32fe7c5ed2a9338e3d8a4447f57cef5fb Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 6 Mar 2016 22:49:55 +0100 Subject: [PATCH 10/21] Adds run instructions to every playground page. --- .../Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Pages/Index.xcplaygroundpage/Contents.swift | 2 +- .../Pages/Introduction.xcplaygroundpage/Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ .../Pages/Subjects.xcplaygroundpage/Contents.swift | 9 +++++++++ .../Contents.swift | 9 +++++++++ 11 files changed, 91 insertions(+), 1 deletion(-) diff --git a/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift index 7887749b..b4324272 100644 --- a/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift index 9da1d2ec..1e415e25 100644 --- a/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import Cocoa diff --git a/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift index 1bbdd93b..d43f3bf2 100644 --- a/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift index 71f812ca..e7adfcc7 100644 --- a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift index 1f6406f1..8f2d260a 100644 --- a/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift index cb6598bf..7f4bb155 100644 --- a/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift @@ -1,6 +1,6 @@ /*: -> # IMPORTANT: To use `RxSamples`, please: +> # IMPORTANT: To use `RxPlaygrounds`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift index 81be41fa..acd7837b 100644 --- a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Index](@previous) import RxSwift diff --git a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift index 9e390081..d7de949f 100644 --- a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift index 3010400c..5b040ec6 100644 --- a/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift index e74015e4..a407fbe3 100644 --- a/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift diff --git a/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift index f0216cf5..eb20a3f1 100644 --- a/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift @@ -1,3 +1,12 @@ +/*: +> # IMPORTANT: To use `RxPlaygrounds`, please: + +1. Open `Rx.xcworkspace` +2. Build `RxSwift-OSX` scheme +3. And then open `Rx` playground in `Rx.xcworkspace` tree view. +4. Choose `View > Show Debug Area` +*/ + //: [<< Previous](@previous) - [Index](Index) import RxSwift From e5735611c96af426e558e5a33a2687d7efc121be Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 6 Mar 2016 22:51:35 +0100 Subject: [PATCH 11/21] Improves playground documentation. #531 --- .../Pages/Combining_Observables.xcplaygroundpage/Contents.swift | 2 +- .../Contents.swift | 2 +- .../Contents.swift | 2 +- .../Error_Handling_Operators.xcplaygroundpage/Contents.swift | 2 +- .../Pages/Filtering_Observables.xcplaygroundpage/Contents.swift | 2 +- Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift | 2 +- .../Pages/Introduction.xcplaygroundpage/Contents.swift | 2 +- .../Contents.swift | 2 +- .../Contents.swift | 2 +- Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift | 2 +- .../Transforming_Observables.xcplaygroundpage/Contents.swift | 2 +- Rx.playground/contents.xcplayground | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift index b4324272..8935a67f 100644 --- a/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Combining_Observables.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift index 1e415e25..d14a2cda 100644 --- a/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Conditional_and_Boolean_Operators.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift index d43f3bf2..208caf56 100644 --- a/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Connectable_Observable_Operators.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift index e7adfcc7..206279e9 100644 --- a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift index 8f2d260a..29405905 100644 --- a/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Filtering_Observables.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift index 7f4bb155..720c1a62 100644 --- a/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift @@ -1,6 +1,6 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift index acd7837b..04994d5a 100644 --- a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift index d7de949f..a6b78f35 100644 --- a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift index 5b040ec6..a1230154 100644 --- a/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Observable_Utility_Operators.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift index a407fbe3..dc8df166 100644 --- a/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Subjects.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift index eb20a3f1..57f978b5 100644 --- a/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Transforming_Observables.xcplaygroundpage/Contents.swift @@ -1,5 +1,5 @@ /*: -> # IMPORTANT: To use `RxPlaygrounds`, please: +> # IMPORTANT: To use `Rx.playground`, please: 1. Open `Rx.xcworkspace` 2. Build `RxSwift-OSX` scheme diff --git a/Rx.playground/contents.xcplayground b/Rx.playground/contents.xcplayground index 0d291cc1..f511ccd7 100644 --- a/Rx.playground/contents.xcplayground +++ b/Rx.playground/contents.xcplayground @@ -1,5 +1,5 @@ - + From 863678639d332305fe04eb2455df989fd929a792 Mon Sep 17 00:00:00 2001 From: Denis Lebedev Date: Mon, 7 Mar 2016 17:13:14 +0000 Subject: [PATCH 12/21] Fix grammar errors and add some dots. --- RxSwift/Errors.swift | 10 +++++----- RxSwift/Observable+Extensions.swift | 4 ++-- RxSwift/ObservableType.swift | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RxSwift/Errors.swift b/RxSwift/Errors.swift index 270f101c..ccb71c19 100644 --- a/RxSwift/Errors.swift +++ b/RxSwift/Errors.swift @@ -34,11 +34,11 @@ public enum RxError */ case ArgumentOutOfRange /** - Sequence doesn't contain any element. + Sequence doesn't contain any elements. */ case NoElements /** - Sequence contains more then one element. + Sequence contains more than one element. */ case MoreThanOneElement /** @@ -62,11 +62,11 @@ public extension RxError { case .ArgumentOutOfRange: return "Argument out of range." case .NoElements: - return "Sequence doesn't contain any element." + return "Sequence doesn't contain any elements." case .MoreThanOneElement: - return "Sequence contains more then one element." + return "Sequence contains more than one element." case .Timeout: - return "Sequence timeout" + return "Sequence timeout." } } } \ No newline at end of file diff --git a/RxSwift/Observable+Extensions.swift b/RxSwift/Observable+Extensions.swift index fb32066f..c44b9b05 100644 --- a/RxSwift/Observable+Extensions.swift +++ b/RxSwift/Observable+Extensions.swift @@ -31,7 +31,7 @@ extension ObservableType { - parameter onError: Action to invoke upon errored termination of the observable sequence. - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has - gracefully completed, errored, or if the generation is cancelled by disposing subscription) + gracefully completed, errored, or if the generation is cancelled by disposing subscription). - returns: Subscription object used to unsubscribe from the observable sequence. */ @warn_unused_result(message="http://git.io/rxs.ud") @@ -119,7 +119,7 @@ extension ObservableType { public extension ObservableType { /** - All internal subscribe calls go through this method + All internal subscribe calls go through this method. */ @warn_unused_result(message="http://git.io/rxs.ud") func subscribeSafe(observer: O) -> Disposable { diff --git a/RxSwift/ObservableType.swift b/RxSwift/ObservableType.swift index 4ed114cc..7594bc51 100644 --- a/RxSwift/ObservableType.swift +++ b/RxSwift/ObservableType.swift @@ -25,7 +25,7 @@ public protocol ObservableType : ObservableConvertibleType { **Next\* (Error | Completed)?** * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` - * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other element + * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements It is possible that events are sent from different threads, but no two events can be sent concurrently to `observer`. From 0567020538a10e1aa7d5fea6b53182fb16bbb08b Mon Sep 17 00:00:00 2001 From: Denis Lebedev Date: Mon, 7 Mar 2016 17:31:00 +0000 Subject: [PATCH 13/21] Simplify computed properties --- RxCocoa/iOS/UICollectionView+Rx.swift | 4 +- .../RxDataSourceStarterKit/Changeset.swift | 12 ++--- .../Differentiator.swift | 32 ++++++-------- .../RxDataSourceStarterKit/SectionModel.swift | 12 ++--- .../TableViewWithEditingCommands/User.swift | 4 +- .../Services/ReachabilityService.swift | 4 +- RxSwift/DataStructures/Bag.swift | 16 +++---- RxSwift/DataStructures/Queue.swift | 14 ++---- RxSwift/Disposables/AnonymousDisposable.swift | 4 +- RxSwift/Disposables/BinaryDisposable.swift | 4 +- RxSwift/Disposables/BooleanDisposable.swift | 4 +- RxSwift/Disposables/CompositeDisposable.swift | 12 ++--- RxSwift/Disposables/RefCountDisposable.swift | 6 +-- RxSwift/Disposables/ScheduledDisposable.swift | 4 +- RxSwift/Disposables/SerialDisposable.swift | 4 +- .../SingleAssignmentDisposable.swift | 4 +- RxSwift/Event.swift | 44 ++++++++----------- .../Implementations/WithLatestFrom.swift | 4 +- RxSwift/RxMutableBox.swift | 4 +- .../ConcurrentDispatchQueueScheduler.swift | 4 +- .../Schedulers/ConcurrentMainScheduler.swift | 4 +- .../Schedulers/Internal/ScheduledItem.swift | 4 +- .../SerialDispatchQueueScheduler.swift | 4 +- RxSwift/Schedulers/VirtualTimeScheduler.swift | 8 +--- RxSwift/Subjects/PublishSubject.swift | 4 +- RxTests/Recorded.swift | 4 +- RxTests/Subscription.swift | 10 ++--- Tests/RxCocoaTests/DelegateProxyTest.swift | 4 +- .../TestImplementations/Mocks/MySubject.swift | 8 +--- Tests/RxTest.swift | 4 +- 30 files changed, 80 insertions(+), 170 deletions(-) diff --git a/RxCocoa/iOS/UICollectionView+Rx.swift b/RxCocoa/iOS/UICollectionView+Rx.swift index 8147c6ac..4bd618f7 100644 --- a/RxCocoa/iOS/UICollectionView+Rx.swift +++ b/RxCocoa/iOS/UICollectionView+Rx.swift @@ -112,9 +112,7 @@ extension UICollectionView { For more information take a look at `DelegateProxyType` protocol documentation. */ public var rx_dataSource: DelegateProxy { - get { - return proxyForObject(RxCollectionViewDataSourceProxy.self, self) - } + return proxyForObject(RxCollectionViewDataSourceProxy.self, self) } /** diff --git a/RxExample/RxDataSourceStarterKit/Changeset.swift b/RxExample/RxDataSourceStarterKit/Changeset.swift index 39989fa3..3673182d 100644 --- a/RxExample/RxDataSourceStarterKit/Changeset.swift +++ b/RxExample/RxDataSourceStarterKit/Changeset.swift @@ -18,9 +18,7 @@ struct ItemPath : CustomDebugStringConvertible { let itemIndex: Int var debugDescription : String { - get { - return "(\(sectionIndex), \(itemIndex))" - } + return "(\(sectionIndex), \(itemIndex))" } } @@ -51,20 +49,18 @@ public struct Changeset : CustomDebugStringConvertible { } public var debugDescription : String { - get { - let serializedSections = "[\n" + finalSections.map { "\($0)" }.joinWithSeparator(",\n") + "\n]\n" - return " >> Final sections" + let serializedSections = "[\n" + finalSections.map { "\($0)" }.joinWithSeparator(",\n") + "\n]\n" + return " >> Final sections" + " \n\(serializedSections)" + (insertedSections.count > 0 || deletedSections.count > 0 || movedSections.count > 0 || updatedSections.count > 0 ? "\nSections:" : "") + (insertedSections.count > 0 ? "\ninsertedSections:\n\t\(insertedSections)" : "") + (deletedSections.count > 0 ? "\ndeletedSections:\n\t\(deletedSections)" : "") + (movedSections.count > 0 ? "\nmovedSections:\n\t\(movedSections)" : "") + (updatedSections.count > 0 ? "\nupdatesSections:\n\t\(updatedSections)" : "") - + (insertedItems.count > 0 || deletedItems.count > 0 || movedItems.count > 0 || updatedItems.count > 0 ? "\nItems:" : "") + + (insertedItems.count > 0 || deletedItems.count > 0 || movedItems.count > 0 || updatedItems.count > 0 ? "\nItems:" : "") + (insertedItems.count > 0 ? "\ninsertedItems:\n\t\(insertedItems)" : "") + (deletedItems.count > 0 ? "\ndeletedItems:\n\t\(deletedItems)" : "") + (movedItems.count > 0 ? "\nmovedItems:\n\t\(movedItems)" : "") + (updatedItems.count > 0 ? "\nupdatedItems:\n\t\(updatedItems)" : "") - } } } diff --git a/RxExample/RxDataSourceStarterKit/Differentiator.swift b/RxExample/RxDataSourceStarterKit/Differentiator.swift index 24a775dd..51154ce7 100644 --- a/RxExample/RxDataSourceStarterKit/Differentiator.swift +++ b/RxExample/RxDataSourceStarterKit/Differentiator.swift @@ -33,19 +33,17 @@ enum EditEvent : CustomDebugStringConvertible { extension EditEvent { var debugDescription: String { - get { - switch self { - case .Inserted: - return "Inserted" - case .Deleted: - return "Deleted" - case .Moved: - return "Moved" - case .MovedAutomatically: - return "MovedAutomatically" - case .Untouched: - return "Untouched" - } + switch self { + case .Inserted: + return "Inserted" + case .Deleted: + return "Deleted" + case .Moved: + return "Moved" + case .MovedAutomatically: + return "MovedAutomatically" + case .Untouched: + return "Untouched" } } } @@ -57,9 +55,7 @@ struct SectionAdditionalInfo : CustomDebugStringConvertible { extension SectionAdditionalInfo { var debugDescription: String { - get { - return "\(event), \(indexAfterDelete)" - } + return "\(event), \(indexAfterDelete)" } } @@ -70,9 +66,7 @@ struct ItemAdditionalInfo : CustomDebugStringConvertible { extension ItemAdditionalInfo { var debugDescription: String { - get { - return "\(event) \(indexAfterDelete)" - } + return "\(event) \(indexAfterDelete)" } } diff --git a/RxExample/RxDataSourceStarterKit/SectionModel.swift b/RxExample/RxDataSourceStarterKit/SectionModel.swift index 2a645fb6..3a6ead4b 100644 --- a/RxExample/RxDataSourceStarterKit/SectionModel.swift +++ b/RxExample/RxDataSourceStarterKit/SectionModel.swift @@ -25,9 +25,7 @@ public struct SectionModel : SectionModelType, CustomStringCo } public var description: String { - get { - return "\(self.model) > \(items)" - } + return "\(self.model) > \(items)" } } @@ -48,15 +46,11 @@ public struct HashableSectionModel : Hash } public var description: String { - get { - return "HashableSectionModel(model: \"\(self.model)\", items: \(items))" - } + return "HashableSectionModel(model: \"\(self.model)\", items: \(items))" } public var hashValue: Int { - get { - return self.model.hashValue - } + return self.model.hashValue } } diff --git a/RxExample/RxExample/Examples/TableViewWithEditingCommands/User.swift b/RxExample/RxExample/Examples/TableViewWithEditingCommands/User.swift index 239ea9b5..ec5842fa 100755 --- a/RxExample/RxExample/Examples/TableViewWithEditingCommands/User.swift +++ b/RxExample/RxExample/Examples/TableViewWithEditingCommands/User.swift @@ -23,9 +23,7 @@ struct User: Equatable, CustomDebugStringConvertible { extension User { var debugDescription: String { - get { - return firstName + " " + lastName - } + return firstName + " " + lastName } } diff --git a/RxExample/RxExample/Services/ReachabilityService.swift b/RxExample/RxExample/Services/ReachabilityService.swift index 8419f4cd..fe51c95f 100644 --- a/RxExample/RxExample/Services/ReachabilityService.swift +++ b/RxExample/RxExample/Services/ReachabilityService.swift @@ -20,9 +20,7 @@ class ReachabilityService { private let _reachabilityChangedSubject = PublishSubject() private var reachabilityChanged: Observable { - get { - return _reachabilityChangedSubject.asObservable() - } + return _reachabilityChangedSubject.asObservable() } // singleton diff --git a/RxSwift/DataStructures/Bag.swift b/RxSwift/DataStructures/Bag.swift index 8b5f739c..fe074dec 100644 --- a/RxSwift/DataStructures/Bag.swift +++ b/RxSwift/DataStructures/Bag.swift @@ -35,13 +35,11 @@ public struct BagKey : Hashable { let key: Int public var hashValue: Int { - get { - if let uniqueIdentity = uniqueIdentity { - return hash(key) ^ (unsafeAddressOf(uniqueIdentity).hashValue) - } - else { - return hash(key) - } + if let uniqueIdentity = uniqueIdentity { + return hash(key) ^ (unsafeAddressOf(uniqueIdentity).hashValue) + } + else { + return hash(key) } } } @@ -212,9 +210,7 @@ extension Bag { A textual representation of `self`, suitable for debugging. */ public var debugDescription : String { - get { - return "\(self.count) elements in Bag" - } + return "\(self.count) elements in Bag" } } diff --git a/RxSwift/DataStructures/Queue.swift b/RxSwift/DataStructures/Queue.swift index 010ed9be..3b97b5f0 100644 --- a/RxSwift/DataStructures/Queue.swift +++ b/RxSwift/DataStructures/Queue.swift @@ -49,28 +49,22 @@ public struct Queue: SequenceType { } private var dequeueIndex: Int { - get { - let index = _pushNextIndex - count - return index < 0 ? index + _storage.count : index - } + let index = _pushNextIndex - count + return index < 0 ? index + _storage.count : index } /** - returns: Is queue empty. */ public var isEmpty: Bool { - get { - return count == 0 - } + return count == 0 } /** - returns: Number of elements inside queue. */ public var count: Int { - get { - return _count - } + return _count } /** diff --git a/RxSwift/Disposables/AnonymousDisposable.swift b/RxSwift/Disposables/AnonymousDisposable.swift index ee78c141..17a40910 100644 --- a/RxSwift/Disposables/AnonymousDisposable.swift +++ b/RxSwift/Disposables/AnonymousDisposable.swift @@ -23,9 +23,7 @@ public final class AnonymousDisposable : DisposeBase, Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - return _disposed == 1 - } + return _disposed == 1 } /** diff --git a/RxSwift/Disposables/BinaryDisposable.swift b/RxSwift/Disposables/BinaryDisposable.swift index d2330ecb..b6176592 100644 --- a/RxSwift/Disposables/BinaryDisposable.swift +++ b/RxSwift/Disposables/BinaryDisposable.swift @@ -23,9 +23,7 @@ public final class BinaryDisposable : DisposeBase, Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - return _disposed > 0 - } + return _disposed > 0 } /** diff --git a/RxSwift/Disposables/BooleanDisposable.swift b/RxSwift/Disposables/BooleanDisposable.swift index a1382155..05b8a43d 100644 --- a/RxSwift/Disposables/BooleanDisposable.swift +++ b/RxSwift/Disposables/BooleanDisposable.swift @@ -33,9 +33,7 @@ public class BooleanDisposable : Disposable, Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - return _disposed - } + return _disposed } /** diff --git a/RxSwift/Disposables/CompositeDisposable.swift b/RxSwift/Disposables/CompositeDisposable.swift index 2ebf8f38..dbf50681 100644 --- a/RxSwift/Disposables/CompositeDisposable.swift +++ b/RxSwift/Disposables/CompositeDisposable.swift @@ -20,10 +20,8 @@ public class CompositeDisposable : DisposeBase, Disposable, Cancelable { private var _disposables: Bag? = Bag() public var disposed: Bool { - get { - _lock.lock(); defer { _lock.unlock() } - return _disposables == nil - } + _lock.lock(); defer { _lock.unlock() } + return _disposables == nil } public override init() { @@ -82,10 +80,8 @@ public class CompositeDisposable : DisposeBase, Disposable, Cancelable { - returns: Gets the number of disposables contained in the `CompositeDisposable`. */ public var count: Int { - get { - _lock.lock(); defer { _lock.unlock() } - return _disposables?.count ?? 0 - } + _lock.lock(); defer { _lock.unlock() } + return _disposables?.count ?? 0 } /** diff --git a/RxSwift/Disposables/RefCountDisposable.swift b/RxSwift/Disposables/RefCountDisposable.swift index 2bd13175..2d29d74a 100644 --- a/RxSwift/Disposables/RefCountDisposable.swift +++ b/RxSwift/Disposables/RefCountDisposable.swift @@ -21,10 +21,8 @@ public class RefCountDisposable : DisposeBase, Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - _lock.lock(); defer { _lock.unlock() } - return _disposable == nil - } + _lock.lock(); defer { _lock.unlock() } + return _disposable == nil } /** diff --git a/RxSwift/Disposables/ScheduledDisposable.swift b/RxSwift/Disposables/ScheduledDisposable.swift index 1a1b0cd7..03c7e695 100644 --- a/RxSwift/Disposables/ScheduledDisposable.swift +++ b/RxSwift/Disposables/ScheduledDisposable.swift @@ -28,9 +28,7 @@ public class ScheduledDisposable : Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - return _disposed == 1 - } + return _disposed == 1 } /** diff --git a/RxSwift/Disposables/SerialDisposable.swift b/RxSwift/Disposables/SerialDisposable.swift index 4371fdca..cb5c4e31 100644 --- a/RxSwift/Disposables/SerialDisposable.swift +++ b/RxSwift/Disposables/SerialDisposable.swift @@ -22,9 +22,7 @@ public class SerialDisposable : DisposeBase, Cancelable { - returns: Was resource disposed. */ public var disposed: Bool { - get { - return _disposed - } + return _disposed } /** diff --git a/RxSwift/Disposables/SingleAssignmentDisposable.swift b/RxSwift/Disposables/SingleAssignmentDisposable.swift index 51d4c560..a3389c11 100644 --- a/RxSwift/Disposables/SingleAssignmentDisposable.swift +++ b/RxSwift/Disposables/SingleAssignmentDisposable.swift @@ -25,9 +25,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable { - returns: A value that indicates whether the object is disposed. */ public var disposed: Bool { - get { - return _disposed - } + return _disposed } /** diff --git a/RxSwift/Event.swift b/RxSwift/Event.swift index ee259528..32b2780c 100644 --- a/RxSwift/Event.swift +++ b/RxSwift/Event.swift @@ -37,15 +37,13 @@ extension Event { - returns: Description of event */ public var debugDescription: String { - get { - switch self { - case .Next(let value): - return "Next(\(value))" - case .Error(let error): - return "Error(\(error))" - case .Completed: - return "Completed" - } + switch self { + case .Next(let value): + return "Next(\(value))" + case .Error(let error): + return "Error(\(error))" + case .Completed: + return "Completed" } } } @@ -55,35 +53,29 @@ extension Event { - returns: Is `Completed` or `Error` event */ public var isStopEvent: Bool { - get { - switch self { - case .Next: return false - case .Error, .Completed: return true - } + switch self { + case .Next: return false + case .Error, .Completed: return true } } - + /** - returns: If `Next` event, returns element value. */ public var element: Element? { - get { - if case .Next(let value) = self { - return value - } - return nil + if case .Next(let value) = self { + return value } + return nil } - + /** - returns: If `Error` event, returns error. */ public var error: ErrorType? { - get { - if case .Error(let error) = self { - return error - } - return nil + if case .Error(let error) = self { + return error } + return nil } } \ No newline at end of file diff --git a/RxSwift/Observables/Implementations/WithLatestFrom.swift b/RxSwift/Observables/Implementations/WithLatestFrom.swift index 39a7eb0c..0ac25f7d 100644 --- a/RxSwift/Observables/Implementations/WithLatestFrom.swift +++ b/RxSwift/Observables/Implementations/WithLatestFrom.swift @@ -76,9 +76,7 @@ class WithLatestFromSecond private let _disposable = SingleAssignmentDisposable() var disposed: Bool { - get { - return _disposable.disposed - } + return _disposable.disposed } init(action: Action, state: T) { diff --git a/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift b/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift index 3d30d630..82e83e3b 100644 --- a/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift +++ b/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift @@ -35,9 +35,7 @@ public class SerialDispatchQueueScheduler: SchedulerType { - returns: Current time. */ public var now : NSDate { - get { - return NSDate() - } + return NSDate() } // leeway for scheduling timers diff --git a/RxSwift/Schedulers/VirtualTimeScheduler.swift b/RxSwift/Schedulers/VirtualTimeScheduler.swift index 03b542ae..41716839 100644 --- a/RxSwift/Schedulers/VirtualTimeScheduler.swift +++ b/RxSwift/Schedulers/VirtualTimeScheduler.swift @@ -251,9 +251,7 @@ extension VirtualTimeScheduler { A textual representation of `self`, suitable for debugging. */ public var debugDescription: String { - get { - return self._schedulerQueue.debugDescription - } + return self._schedulerQueue.debugDescription } } @@ -266,9 +264,7 @@ class VirtualSchedulerItem