Use array literal for option sets

This commit is contained in:
yury 2015-09-26 18:38:41 +03:00
parent 8740e4b853
commit 9917402001
4 changed files with 11 additions and 11 deletions

View File

@ -29,7 +29,7 @@ extension NSObject {
For more information take a look at `rx_observe` method.
*/
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial), retainSelf: Bool = true) -> Observable<CGRect?> {
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial], retainSelf: Bool = true) -> Observable<CGRect?> {
return rx_observe(keyPath, options: options, retainSelf: retainSelf)
.map { (value: NSValue?) in
if let value = value {
@ -51,7 +51,7 @@ extension NSObject {
For more information take a look at `rx_observe` method.
*/
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial), retainSelf: Bool = true) -> Observable<CGSize?> {
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial], retainSelf: Bool = true) -> Observable<CGSize?> {
return rx_observe(keyPath, options: options, retainSelf: retainSelf)
.map { (value: NSValue?) in
if let value = value {
@ -73,7 +73,7 @@ extension NSObject {
For more information take a look at `rx_observe` method.
*/
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial), retainSelf: Bool = true) -> Observable<CGPoint?> {
public func rx_observe(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial], retainSelf: Bool = true) -> Observable<CGPoint?> {
return rx_observe(keyPath, options: options, retainSelf: retainSelf)
.map { (value: NSValue?) in
if let value = value {
@ -101,7 +101,7 @@ extension NSObject {
For more information take a look at `rx_observeWeakly` method.
*/
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial)) -> Observable<CGRect?> {
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial]) -> Observable<CGRect?> {
return rx_observeWeakly(keyPath, options: options)
.map { (value: NSValue?) in
if let value = value {
@ -123,7 +123,7 @@ extension NSObject {
For more information take a look at `rx_observeWeakly` method.
*/
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial)) -> Observable<CGSize?> {
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial]) -> Observable<CGSize?> {
return rx_observeWeakly(keyPath, options: options)
.map { (value: NSValue?) in
if let value = value {
@ -145,7 +145,7 @@ extension NSObject {
For more information take a look at `rx_observeWeakly` method.
*/
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial)) -> Observable<CGPoint?> {
public func rx_observeWeakly(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial]) -> Observable<CGPoint?> {
return rx_observeWeakly(keyPath, options: options)
.map { (value: NSValue?) in
if let value = value {

View File

@ -58,7 +58,7 @@ extension NSObject {
- parameter retainSelf: Retains self during observation if set `true`.
- returns: Observable sequence of objects on `keyPath`.
*/
public func rx_observe<Element>(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial), retainSelf: Bool = true) -> Observable<Element?> {
public func rx_observe<Element>(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial], retainSelf: Bool = true) -> Observable<Element?> {
return KVOObservable(object: self, keyPath: keyPath, options: options, retainTarget: retainSelf)
}
@ -82,7 +82,7 @@ extension NSObject {
- parameter options: KVO mechanism notification options.
- returns: Observable sequence of objects on `keyPath`.
*/
public func rx_observeWeakly<Element>(keyPath: String, options: NSKeyValueObservingOptions = NSKeyValueObservingOptions.New.union(NSKeyValueObservingOptions.Initial)) -> Observable<Element?> {
public func rx_observeWeakly<Element>(keyPath: String, options: NSKeyValueObservingOptions = [.New, .Initial]) -> Observable<Element?> {
return observeWeaklyKeyPathFor(self, keyPath: keyPath, options: options)
.map { n in
return n as? Element

View File

@ -60,7 +60,7 @@ extension UIControl {
observer.on(.Next(getter()))
let controlTarget = ControlTarget(control: self, controlEvents: UIControlEvents.EditingChanged.union(.ValueChanged)) { control in
let controlTarget = ControlTarget(control: self, controlEvents: [.EditingChanged, .ValueChanged]) { control in
observer.on(.Next(getter()))
}

View File

@ -32,7 +32,7 @@ class Parent : NSObject {
init(callback: String? -> Void) {
super.init()
self.rx_observe("val", options: NSKeyValueObservingOptions.Initial.union(.New), retainSelf: false)
self.rx_observe("val", options: [.Initial, .New], retainSelf: false)
.subscribeNext(callback)
.addDisposableTo(disposeBag)
}
@ -47,7 +47,7 @@ class Child : NSObject {
init(parent: ParentWithChild, callback: String? -> Void) {
super.init()
parent.rx_observe("val", options: NSKeyValueObservingOptions.Initial.union(.New), retainSelf: false)
parent.rx_observe("val", options: [.Initial, .New], retainSelf: false)
.subscribeNext(callback)
.addDisposableTo(disposeBag)
}