Skip to content
Permalink
Browse files

Update E to Element in RxSwift

  • Loading branch information...
freak4pc authored and kzaher committed Apr 22, 2019
1 parent eef9a2d commit 991e955297eea21c447a330be059e74cfa2a5500
Showing with 691 additions and 695 deletions.
  1. +4 −5 Platform/DataStructures/InfiniteSequence.swift
  2. +5 −5 RxSwift/AnyObserver.swift
  3. +2 −2 RxSwift/Concurrency/SynchronizedOnType.swift
  4. +26 −26 RxSwift/Deprecated.swift
  5. +2 −2 RxSwift/Event.swift
  6. +1 −1 RxSwift/Extensions/Bag+Rx.swift
  7. +2 −2 RxSwift/GroupedObservable.swift
  8. +2 −5 RxSwift/Observable.swift
  9. +3 −3 RxSwift/ObservableType+Extensions.swift
  10. +2 −2 RxSwift/ObservableType.swift
  11. +2 −2 RxSwift/Observables/AddRef.swift
  12. +7 −7 RxSwift/Observables/Amb.swift
  13. +5 −5 RxSwift/Observables/AsMaybe.swift
  14. +5 −5 RxSwift/Observables/AsSingle.swift
  15. +6 −6 RxSwift/Observables/Buffer.swift
  16. +20 −20 RxSwift/Observables/Catch.swift
  17. +7 −7 RxSwift/Observables/CombineLatest+Collection.swift
  18. +42 −42 RxSwift/Observables/CombineLatest+arity.swift
  19. +5 −5 RxSwift/Observables/CombineLatest+arity.tt
  20. +1 −1 RxSwift/Observables/CombineLatest.swift
  21. +3 −3 RxSwift/Observables/CompactMap.swift
  22. +13 −13 RxSwift/Observables/Concat.swift
  23. +5 −5 RxSwift/Observables/Create.swift
  24. +3 −3 RxSwift/Observables/Debounce.swift
  25. +5 −5 RxSwift/Observables/Debug.swift
  26. +6 −6 RxSwift/Observables/DefaultIfEmpty.swift
  27. +7 −7 RxSwift/Observables/Deferred.swift
  28. +8 −8 RxSwift/Observables/Delay.swift
  29. +4 −4 RxSwift/Observables/DelaySubscription.swift
  30. +11 −11 RxSwift/Observables/Dematerialize.swift
  31. +13 −13 RxSwift/Observables/DistinctUntilChanged.swift
  32. +4 −4 RxSwift/Observables/Do.swift
  33. +3 −3 RxSwift/Observables/ElementAt.swift
  34. +3 −3 RxSwift/Observables/Empty.swift
  35. +4 −4 RxSwift/Observables/Enumerated.swift
  36. +2 −2 RxSwift/Observables/Error.swift
  37. +4 −4 RxSwift/Observables/Filter.swift
  38. +5 −5 RxSwift/Observables/First.swift
  39. +6 −6 RxSwift/Observables/Generate.swift
  40. +7 −7 RxSwift/Observables/GroupBy.swift
  41. +5 −5 RxSwift/Observables/Just.swift
  42. +3 −3 RxSwift/Observables/Map.swift
  43. +8 −8 RxSwift/Observables/Materialize.swift
  44. +43 −43 RxSwift/Observables/Merge.swift
  45. +24 −24 RxSwift/Observables/Multicast.swift
  46. +2 −2 RxSwift/Observables/Never.swift
  47. +17 −17 RxSwift/Observables/ObserveOn.swift
  48. +13 −13 RxSwift/Observables/Optional.swift
  49. +2 −2 RxSwift/Observables/Producer.swift
  50. +11 −11 RxSwift/Observables/Range.swift
  51. +4 −4 RxSwift/Observables/Reduce.swift
  52. +3 −3 RxSwift/Observables/Repeat.swift
  53. +17 −17 RxSwift/Observables/RetryWhen.swift
  54. +6 −6 RxSwift/Observables/Sample.swift
  55. +5 −5 RxSwift/Observables/Scan.swift
  56. +5 −5 RxSwift/Observables/Sequence.swift
  57. +13 −13 RxSwift/Observables/ShareReplayScope.swift
  58. +7 −7 RxSwift/Observables/SingleAsync.swift
  59. +3 −3 RxSwift/Observables/Sink.swift
  60. +6 −6 RxSwift/Observables/Skip.swift
  61. +9 −9 RxSwift/Observables/SkipUntil.swift
  62. +3 −3 RxSwift/Observables/SkipWhile.swift
  63. +3 −3 RxSwift/Observables/StartWith.swift
  64. +5 −5 RxSwift/Observables/SubscribeOn.swift
  65. +18 −18 RxSwift/Observables/Switch.swift
  66. +12 −12 RxSwift/Observables/SwitchIfEmpty.swift
  67. +11 −11 RxSwift/Observables/Take.swift
  68. +7 −7 RxSwift/Observables/TakeLast.swift
  69. +13 −13 RxSwift/Observables/TakeUntil.swift
  70. +4 −4 RxSwift/Observables/TakeWhile.swift
  71. +3 −3 RxSwift/Observables/Throttle.swift
  72. +6 −6 RxSwift/Observables/Timeout.swift
  73. +11 −11 RxSwift/Observables/Timer.swift
  74. +3 −3 RxSwift/Observables/ToArray.swift
  75. +4 −4 RxSwift/Observables/Using.swift
  76. +6 −6 RxSwift/Observables/Window.swift
  77. +11 −11 RxSwift/Observables/WithLatestFrom.swift
  78. +7 −7 RxSwift/Observables/Zip+Collection.swift
  79. +42 −42 RxSwift/Observables/Zip+arity.swift
  80. +5 −5 RxSwift/Observables/Zip+arity.tt
  81. +4 −4 RxSwift/Observables/Zip.swift
  82. +3 −3 RxSwift/Observers/ObserverBase.swift
  83. +5 −5 RxSwift/Observers/TailRecursiveSink.swift
  84. +4 −4 RxSwift/Subjects/AsyncSubject.swift
  85. +4 −4 RxSwift/Subjects/BehaviorSubject.swift
  86. +3 −3 RxSwift/Subjects/PublishSubject.swift
  87. +7 −7 RxSwift/Subjects/ReplaySubject.swift
  88. +9 −9 RxSwift/Traits/Completable+AndThen.swift
  89. +4 −4 RxSwift/Traits/ObservableType+PrimitiveSequence.swift
  90. +3 −3 RxSwift/Traits/PrimitiveSequence.swift
@@ -7,13 +7,12 @@
//
/// Sequence that repeats `repeatedValue` infinite number of times.
struct InfiniteSequence<E> : Sequence {
typealias Element = E
typealias Iterator = AnyIterator<E>
struct InfiniteSequence<Element> : Sequence {
typealias Iterator = AnyIterator<Element>

private let _repeatedValue: E
private let _repeatedValue: Element

init(repeatedValue: E) {
init(repeatedValue: Element) {
_repeatedValue = repeatedValue
}

@@ -11,7 +11,7 @@
/// Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type.
public struct AnyObserver<Element> : ObserverType {
/// The type of elements in sequence that observer can observe.
public typealias E = Element
public typealias Element = Element

/// Anonymous event handler type.
public typealias EventHandler = (Event<Element>) -> Void
@@ -28,7 +28,7 @@ public struct AnyObserver<Element> : ObserverType {
/// Construct an instance whose `on(event)` calls `observer.on(event)`
///
/// - parameter observer: Observer that receives sequence events.
public init<O : ObserverType>(_ observer: O) where O.E == Element {
public init<O : ObserverType>(_ observer: O) where O.Element == Element {
self.observer = observer.on
}

@@ -42,7 +42,7 @@ public struct AnyObserver<Element> : ObserverType {
/// Erases type of observer and returns canonical observer.
///
/// - returns: type erased observer.
public func asObserver() -> AnyObserver<E> {
public func asObserver() -> AnyObserver<Element> {
return self
}
}
@@ -56,15 +56,15 @@ extension ObserverType {
/// Erases type of observer and returns canonical observer.
///
/// - returns: type erased observer.
public func asObserver() -> AnyObserver<E> {
public func asObserver() -> AnyObserver<Element> {
return AnyObserver(self)
}

/// Transforms observer of type R to type E using custom transform method.
/// Each event sent to result observer is transformed and sent to `self`.
///
/// - returns: observer that transforms events.
public func mapObserver<R>(_ transform: @escaping (R) throws -> E) -> AnyObserver<R> {
public func mapObserver<R>(_ transform: @escaping (R) throws -> Element) -> AnyObserver<R> {
return AnyObserver { e in
self.on(e.map(transform))
}
@@ -7,11 +7,11 @@
//
protocol SynchronizedOnType : class, ObserverType, Lock {
func _synchronized_on(_ event: Event<E>)
func _synchronized_on(_ event: Event<Element>)
}

extension SynchronizedOnType {
func synchronizedOn(_ event: Event<E>) {
func synchronizedOn(_ event: Event<Element>) {
self.lock(); defer { self.unlock() }
self._synchronized_on(event)
}
@@ -18,7 +18,7 @@ extension Observable {
- returns: An observable sequence containing the wrapped value or not from given optional.
*/
@available(*, deprecated, message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.", renamed: "from(optional:)")
public static func from(_ optional: E?) -> Observable<E> {
public static func from(_ optional: Element?) -> Observable<Element> {
return Observable.from(optional: optional)
}

@@ -32,7 +32,7 @@ extension Observable {
- returns: An observable sequence containing the wrapped value or not from given optional.
*/
@available(*, deprecated, message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.", renamed: "from(optional:scheduler:)")
public static func from(_ optional: E?, scheduler: ImmediateSchedulerType) -> Observable<E> {
public static func from(_ optional: Element?, scheduler: ImmediateSchedulerType) -> Observable<Element> {
return Observable.from(optional: optional, scheduler: scheduler)
}
}
@@ -48,7 +48,7 @@ extension ObservableType {
- returns: An observable sequence whose elements are the result of invoking the transform function on each element of source.
*/
@available(*, deprecated, message: "Please use enumerated().map()")
public func mapWithIndex<R>(_ selector: @escaping (E, Int) throws -> R)
public func mapWithIndex<R>(_ selector: @escaping (Element, Int) throws -> R)
-> Observable<R> {
return self.enumerated().map { try selector($0.element, $0.index) }
}
@@ -64,8 +64,8 @@ extension ObservableType {
- returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.
*/
@available(*, deprecated, message: "Please use enumerated().flatMap()")
public func flatMapWithIndex<O: ObservableConvertibleType>(_ selector: @escaping (E, Int) throws -> O)
-> Observable<O.E> {
public func flatMapWithIndex<O: ObservableConvertibleType>(_ selector: @escaping (Element, Int) throws -> O)
-> Observable<O.Element> {
return self.enumerated().flatMap { try selector($0.element, $0.index) }
}

@@ -80,7 +80,7 @@ extension ObservableType {
- returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
*/
@available(*, deprecated, message: "Please use enumerated().skipWhile().map()")
public func skipWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) -> Observable<E> {
public func skipWhileWithIndex(_ predicate: @escaping (Element, Int) throws -> Bool) -> Observable<Element> {
return self.enumerated().skipWhile { try predicate($0.element, $0.index) }.map { $0.element }
}

@@ -97,7 +97,7 @@ extension ObservableType {
- returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
*/
@available(*, deprecated, message: "Please use enumerated().takeWhile().map()")
public func takeWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) -> Observable<E> {
public func takeWhileWithIndex(_ predicate: @escaping (Element, Int) throws -> Bool) -> Observable<Element> {
return self.enumerated().takeWhile { try predicate($0.element, $0.index) }.map { $0.element }
}
}
@@ -129,7 +129,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "use share(replay: 1) instead", renamed: "share(replay:)")
public func shareReplayLatestWhileConnected()
-> Observable<E> {
-> Observable<Element> {
return self.share(replay: 1, scope: .whileConnected)
}
}
@@ -149,7 +149,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Suggested replacement is `share(replay: 1)`. In case old 3.x behavior of `shareReplay` is required please use `share(replay: 1, scope: .forever)` instead.", renamed: "share(replay:)")
public func shareReplay(_ bufferSize: Int)
-> Observable<E> {
-> Observable<Element> {
return self.share(replay: bufferSize, scope: .forever)
}
}
@@ -172,14 +172,14 @@ extension ObservableType {
@available(*, deprecated, message: "Variable is deprecated. Please use `BehaviorRelay` as a replacement.")
public final class Variable<Element> {

public typealias E = Element
public typealias Element = Element

private let _subject: BehaviorSubject<Element>

private var _lock = SpinLock()

// state
private var _value: E
private var _value: Element

#if DEBUG
fileprivate let _synchronizationTracker = SynchronizationTracker()
@@ -190,7 +190,7 @@ public final class Variable<Element> {
/// Whenever a new value is set, all the observers are notified of the change.
///
/// Even if the newly set value is same as the old value, observers are still notified for change.
public var value: E {
public var value: Element {
get {
self._lock.lock(); defer { self._lock.unlock() }
return self._value
@@ -217,7 +217,7 @@ public final class Variable<Element> {
}

/// - returns: Canonical interface for push style sequence
public func asObservable() -> Observable<E> {
public func asObservable() -> Observable<Element> {
return self._subject
}

@@ -238,7 +238,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "delay(_:scheduler:)")
public func delay(_ dueTime: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return self.delay(.milliseconds(Int(dueTime * 1000.0)), scheduler: scheduler)
}
}
@@ -256,7 +256,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "timeout(_:scheduler:)")
public func timeout(_ dueTime: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return timeout(.milliseconds(Int(dueTime * 1000.0)), scheduler: scheduler)
}

@@ -272,7 +272,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "timeout(_:other:scheduler:)")
public func timeout<O: ObservableConvertibleType>(_ dueTime: Foundation.TimeInterval, other: O, scheduler: SchedulerType)
-> Observable<E> where E == O.E {
-> Observable<Element> where Element == O.Element {
return timeout(.milliseconds(Int(dueTime * 1000.0)), other: other, scheduler: scheduler)
}
}
@@ -290,12 +290,12 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "skip(_:scheduler:)")
public func skip(_ duration: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return skip(.milliseconds(Int(duration * 1000.0)), scheduler: scheduler)
}
}

extension ObservableType where E : RxAbstractInteger {
extension ObservableType where Element : RxAbstractInteger {
/**
Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
@@ -307,12 +307,12 @@ extension ObservableType where E : RxAbstractInteger {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "interval(_:scheduler:)")
public static func interval(_ period: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return interval(.milliseconds(Int(period * 1000.0)), scheduler: scheduler)
}
}

extension ObservableType where E: RxAbstractInteger {
extension ObservableType where Element: RxAbstractInteger {
/**
Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers.
@@ -325,7 +325,7 @@ extension ObservableType where E: RxAbstractInteger {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "timer(_:period:scheduler:)")
public static func timer(_ dueTime: Foundation.TimeInterval, period: Foundation.TimeInterval? = nil, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return timer(.milliseconds(Int(dueTime * 1000.0)), period: period.map { .milliseconds(Int($0 * 1000.0)) }, scheduler: scheduler)
}
}
@@ -346,7 +346,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "throttle(_:latest:scheduler:)")
public func throttle(_ dueTime: Foundation.TimeInterval, latest: Bool = true, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return throttle(.milliseconds(Int(dueTime * 1000.0)), latest: latest, scheduler: scheduler)
}
}
@@ -364,7 +364,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "take(_:scheduler:)")
public func take(_ duration: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return take(.milliseconds(Int(duration * 1000.0)), scheduler: scheduler)
}
}
@@ -383,7 +383,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "delaySubscription(_:scheduler:)")
public func delaySubscription(_ dueTime: Foundation.TimeInterval, scheduler: SchedulerType)
-> Observable<E> {
-> Observable<Element> {
return delaySubscription(.milliseconds(Int(dueTime * 1000.0)), scheduler: scheduler)
}
}
@@ -402,7 +402,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "window(_:)")
public func window(timeSpan: Foundation.TimeInterval, count: Int, scheduler: SchedulerType)
-> Observable<Observable<E>> {
-> Observable<Observable<Element>> {
return window(timeSpan: .milliseconds(Int(timeSpan * 1000.0)), count: count, scheduler: scheduler)
}
}
@@ -518,7 +518,7 @@ extension ObservableType {
*/
@available(*, deprecated, message: "Use DispatchTimeInterval overload instead.", renamed: "buffer(timeSpan:count:scheduler:)")
public func buffer(timeSpan: Foundation.TimeInterval, count: Int, scheduler: SchedulerType)
-> Observable<[E]> {
-> Observable<[Element]> {
return buffer(timeSpan: .milliseconds(Int(timeSpan * 1000.0)), count: count, scheduler: scheduler)
}
}
@@ -21,7 +21,7 @@ public enum Event<Element> {
case completed
}

extension Event : CustomDebugStringConvertible {
extension Event: CustomDebugStringConvertible {
/// Description of event.
public var debugDescription: String {
switch self {
@@ -98,7 +98,7 @@ public protocol EventConvertible {
var event: Event<ElementType> { get }
}

extension Event : EventConvertible {
extension Event: EventConvertible {
/// Event representation of this instance
public var event: Event<Element> {
return self
@@ -10,7 +10,7 @@
// MARK: forEach
@inline(__always)
func dispatch<E>(_ bag: Bag<(Event<E>) -> Void>, _ event: Event<E>) {
func dispatch<Element>(_ bag: Bag<(Event<Element>) -> Void>, _ event: Event<Element>) {
bag._value0?(event)

if bag._onlyFastPath {
@@ -8,7 +8,7 @@
/// Represents an observable sequence of elements that have a common key.
public struct GroupedObservable<Key, Element> : ObservableType {
public typealias E = Element
public typealias Element = Element

/// Gets the common key.
public let key: Key
@@ -26,7 +26,7 @@ public struct GroupedObservable<Key, Element> : ObservableType {
}

/// Subscribes `observer` to receive events for this sequence.
public func subscribe<O : ObserverType>(_ observer: O) -> Disposable where O.E == E {
public func subscribe<O : ObserverType>(_ observer: O) -> Disposable where O.Element == Element {
return self.source.subscribe(observer)
}

@@ -10,20 +10,17 @@
///
/// It represents a push style sequence.
public class Observable<Element> : ObservableType {
/// Type of elements in sequence.
public typealias E = Element

init() {
#if TRACE_RESOURCES
_ = Resources.incrementTotal()
#endif
}

public func subscribe<O: ObserverType>(_ observer: O) -> Disposable where O.E == E {
public func subscribe<O: ObserverType>(_ observer: O) -> Disposable where O.Element == Element {
rxAbstractMethod()
}

public func asObservable() -> Observable<E> {
public func asObservable() -> Observable<Element> {
return self
}

@@ -17,7 +17,7 @@ extension ObservableType {
- parameter on: Action to invoke for each event in the observable sequence.
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
public func subscribe(_ on: @escaping (Event<E>) -> Void)
public func subscribe(_ on: @escaping (Event<Element>) -> Void)
-> Disposable {
let observer = AnonymousObserver { e in
on(e)
@@ -36,7 +36,7 @@ extension ObservableType {
gracefully completed, errored, or if the generation is canceled by disposing subscription).
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
public func subscribe(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil)
public func subscribe(onNext: ((Element) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil)
-> Disposable {
let disposable: Disposable

@@ -53,7 +53,7 @@ extension ObservableType {

let callStack = Hooks.recordCallStackOnError ? Hooks.customCaptureSubscriptionCallstack() : []

let observer = AnonymousObserver<E> { event in
let observer = AnonymousObserver<Element> { event in

#if DEBUG
synchronizationTracker.register(synchronizationErrorMessage: .default)
Oops, something went wrong.

0 comments on commit 991e955

Please sign in to comment.
You can’t perform that action at this time.