-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from RxSwiftCommunity/develop/emit
Support emit
- Loading branch information
Showing
6 changed files
with
149 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
PODS: | ||
- RxBinding (0.4): | ||
- RxCocoa (< 6.0.0, >= 5.0.0) | ||
- RxSwift (< 6.0.0, >= 5.0.0) | ||
- RxCocoa (5.1.1): | ||
- RxRelay (~> 5) | ||
- RxSwift (~> 5) | ||
- RxRelay (5.1.1): | ||
- RxSwift (~> 5) | ||
- RxSwift (5.1.1) | ||
- SnapKit (5.0.1) | ||
|
||
DEPENDENCIES: | ||
- RxBinding (from `../../`) | ||
- SnapKit | ||
|
||
SPEC REPOS: | ||
trunk: | ||
- RxCocoa | ||
- RxRelay | ||
- RxSwift | ||
- SnapKit | ||
|
||
EXTERNAL SOURCES: | ||
RxBinding: | ||
:path: "../../" | ||
|
||
SPEC CHECKSUMS: | ||
RxBinding: da433c012633802a72c2a5bec8775b86f4cddeb8 | ||
RxCocoa: 32065309a38d29b5b0db858819b5bf9ef038b601 | ||
RxRelay: d77f7d771495f43c556cbc43eebd1bb54d01e8e9 | ||
RxSwift: 81470a2074fa8780320ea5fe4102807cb7118178 | ||
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb | ||
|
||
PODFILE CHECKSUM: 3dc791eedabb6208496ff999c24c1b9d6b616432 | ||
|
||
COCOAPODS: 1.9.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// Emit.swift | ||
// RxBinding | ||
// | ||
// Created by Meng Li on 05/25/2020. | ||
// Copyright (c) 2020 MuShare. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import RxSwift | ||
import RxCocoa | ||
|
||
infix operator ~> : DefaultPrecedence | ||
|
||
// Emit the observer, the relay or the binder. | ||
extension SharedSequenceConvertibleType where SharingStrategy == SignalSharingStrategy { | ||
|
||
public static func ~> <O>(observable: Self, observer: O) -> Disposable where O : ObserverType, Self.Element == O.Element { | ||
return observable.emit(to: observer) | ||
} | ||
|
||
public static func ~> <O>(observable: Self, observer: O) -> Disposable where O : ObserverType, O.Element == Self.Element? { | ||
return observable.emit(to: observer) | ||
} | ||
|
||
public static func ~> (observable: Self, relay: PublishRelay<Self.Element>) -> Disposable { | ||
return observable.emit(to: relay) | ||
} | ||
|
||
public static func ~> (observable: Self, relay: PublishRelay<Self.Element?>) -> Disposable { | ||
return observable.emit(to: relay) | ||
} | ||
|
||
public static func ~> (observable: Self, relay: BehaviorRelay<Self.Element>) -> Disposable { | ||
return observable.emit(to: relay) | ||
} | ||
|
||
public static func ~> (observable: Self, relay: BehaviorRelay<Self.Element?>) -> Disposable { | ||
return observable.emit(to: relay) | ||
} | ||
|
||
} | ||
|
||
// Emit the array of observer, relay or binder. | ||
extension SharedSequenceConvertibleType where SharingStrategy == SignalSharingStrategy { | ||
|
||
public static func ~> <O>(observable: Self, observers: [O]) -> [Disposable] where O : ObserverType, Self.Element == O.Element { | ||
return observers.map { observable.emit(to: $0) } | ||
} | ||
|
||
public static func ~> <O>(observable: Self, observers: [O]) -> [Disposable] where O : ObserverType, O.Element == Self.Element? { | ||
return observers.map { observable.emit(to: $0) } | ||
} | ||
|
||
public static func ~> (observable: Self, relays: [PublishRelay<Self.Element>]) -> [Disposable] { | ||
return relays.map { observable.emit(to: $0) } | ||
} | ||
|
||
public static func ~> (observable: Self, relays: [PublishRelay<Self.Element?>]) -> [Disposable] { | ||
return relays.map { observable.emit(to: $0) } | ||
} | ||
|
||
public static func ~> (observable: Self, relays: [BehaviorRelay<Self.Element>]) -> [Disposable] { | ||
return relays.map { observable.emit(to: $0) } | ||
} | ||
|
||
public static func ~> (observable: Self, relays: [BehaviorRelay<Self.Element?>]) -> [Disposable] { | ||
return relays.map { observable.emit(to: $0) } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters