mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-05 06:27:29 +03:00
Renames abstractMethod
to rxAbstractMethod
.
This commit is contained in:
parent
59678c1da9
commit
007af77912
@ -73,14 +73,22 @@ func bindingErrorToInterface(_ error: Swift.Error) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: Abstract methods
|
||||
|
||||
func rxAbstractMethodWithMessage(_ message: String) -> Swift.Never {
|
||||
rxFatalError(message)
|
||||
/// Swift does not implement abstract methods. This method is used as a runtime check to ensure that methods which intended to be abstract (i.e., they should be implemented in subclasses) are not called directly on the superclass.
|
||||
func rxAbstractMethod(message: String = "Abstract method", file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
rxFatalError(message, file: file, line: line)
|
||||
}
|
||||
|
||||
func rxAbstractMethod() -> Swift.Never {
|
||||
rxFatalError("Abstract method")
|
||||
func rxFatalError(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
// The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours.
|
||||
fatalError(lastMessage(), file: file, line: line)
|
||||
}
|
||||
|
||||
func rxFatalErrorInDebug(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) {
|
||||
#if DEBUG
|
||||
fatalError(lastMessage(), file: file, line: line)
|
||||
#else
|
||||
print("\(file):\(line): \(lastMessage())")
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: casts or fatal error
|
||||
|
@ -26,7 +26,7 @@ final class CollectionViewDataSourceNotSet
|
||||
|
||||
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
rxAbstractMethodWithMessage(dataSourceNotSet)
|
||||
rxAbstractMethod(message: dataSourceNotSet)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ final class TableViewDataSourceNotSet
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
rxAbstractMethodWithMessage(dataSourceNotSet)
|
||||
rxAbstractMethod(message: dataSourceNotSet)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class Observable<Element> : ObservableType {
|
||||
}
|
||||
|
||||
public func subscribe<O: ObserverType>(_ observer: O) -> Disposable where O.E == E {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
public func asObservable() -> Observable<E> {
|
||||
|
@ -34,7 +34,7 @@ class CombineLatestSink<O: ObserverType>
|
||||
}
|
||||
|
||||
func getResult() throws -> Element {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func next(_ index: Int) {
|
||||
|
@ -19,7 +19,7 @@ public class ConnectableObservable<Element>
|
||||
- returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence.
|
||||
*/
|
||||
public func connect() -> Disposable {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,14 @@ final class Do<Element> : Producer<Element> {
|
||||
fileprivate let _source: Observable<Element>
|
||||
fileprivate let _eventHandler: EventHandler
|
||||
fileprivate let _onSubscribe: (() -> ())?
|
||||
fileprivate let _onSubscribed: (() -> ())?
|
||||
fileprivate let _onDispose: (() -> ())?
|
||||
|
||||
init(source: Observable<Element>, eventHandler: @escaping EventHandler, onSubscribe: (() -> ())?, onDispose: (() -> ())?) {
|
||||
init(source: Observable<Element>, eventHandler: @escaping EventHandler, onSubscribe: (() -> ())?, onSubscribed: (() -> ())?, onDispose: (() -> ())?) {
|
||||
_source = source
|
||||
_eventHandler = eventHandler
|
||||
_onSubscribe = onSubscribe
|
||||
_onSubscribed = onSubscribed
|
||||
_onDispose = onDispose
|
||||
}
|
||||
|
||||
@ -51,6 +53,7 @@ final class Do<Element> : Producer<Element> {
|
||||
_onSubscribe?()
|
||||
let sink = DoSink(parent: self, observer: observer, cancel: cancel)
|
||||
let subscription = _source.subscribe(sink)
|
||||
_onSubscribed?()
|
||||
let onDispose = _onDispose
|
||||
let allSubscriptions = Disposables.create {
|
||||
subscription.dispose()
|
||||
|
@ -291,7 +291,7 @@ class MergeSink<SourceType, S: ObservableConvertibleType, O: ObserverType>
|
||||
}
|
||||
|
||||
func performMap(_ element: SourceType) throws -> S {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func on(_ event: Event<SourceType>) {
|
||||
|
@ -32,7 +32,7 @@ class Producer<Element> : Observable<Element> {
|
||||
}
|
||||
|
||||
func run<O : ObserverType>(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class SwitchSink<SourceType, S: ObservableConvertibleType, O: ObserverType>
|
||||
}
|
||||
|
||||
func performMap(_ element: SourceType) throws -> S {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func _synchronized_on(_ event: Event<E>) {
|
||||
|
@ -31,11 +31,11 @@ class ZipSink<O: ObserverType> : Sink<O>, ZipSinkProtocol {
|
||||
}
|
||||
|
||||
func getResult() throws -> Element {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func hasElements(_ index: Int) -> Bool {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func next(_ index: Int) {
|
||||
|
@ -28,7 +28,7 @@ class ObserverBase<ElementType> : Disposable, ObserverType {
|
||||
}
|
||||
|
||||
func onCore(_ event: Event<E>) {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func dispose() {
|
||||
|
@ -62,7 +62,7 @@ class TailRecursiveSink<S: Sequence, O: ObserverType>
|
||||
}
|
||||
|
||||
func extract(_ observable: Observable<E>) -> SequenceGenerator? {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
// should be done on gate locked
|
||||
@ -131,7 +131,7 @@ class TailRecursiveSink<S: Sequence, O: ObserverType>
|
||||
}
|
||||
|
||||
func subscribeToNext(_ source: Observable<E>) -> Disposable {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func disposeCommand() {
|
||||
|
@ -33,13 +33,21 @@
|
||||
#endif
|
||||
|
||||
/// Swift does not implement abstract methods. This method is used as a runtime check to ensure that methods which intended to be abstract (i.e., they should be implemented in subclasses) are not called directly on the superclass.
|
||||
func abstractMethod(file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
func rxAbstractMethod(file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
rxFatalError("Abstract method", file: file, line: line)
|
||||
}
|
||||
|
||||
func rxFatalError(_ lastMessage: String, file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
func rxFatalError(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) -> Swift.Never {
|
||||
// The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours.
|
||||
fatalError(lastMessage, file: file, line: line)
|
||||
fatalError(lastMessage(), file: file, line: line)
|
||||
}
|
||||
|
||||
func rxFatalErrorInDebug(_ lastMessage: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) {
|
||||
#if DEBUG
|
||||
fatalError(lastMessage(), file: file, line: line)
|
||||
#else
|
||||
print("\(file):\(line): \(lastMessage())")
|
||||
#endif
|
||||
}
|
||||
|
||||
func incrementChecked(_ i: inout Int) throws -> Int {
|
||||
|
@ -40,7 +40,7 @@ public class ReplaySubject<Element>
|
||||
fileprivate var _observers = Observers()
|
||||
|
||||
func unsubscribe(_ key: DisposeKey) {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
final var isStopped: Bool {
|
||||
@ -51,7 +51,7 @@ public class ReplaySubject<Element>
|
||||
///
|
||||
/// - parameter event: Event to send to the observers.
|
||||
public func on(_ event: Event<E>) {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
/// Returns observer interface for subject.
|
||||
@ -99,15 +99,15 @@ fileprivate class ReplayBufferBase<Element>
|
||||
, SynchronizedUnsubscribeType {
|
||||
|
||||
func trim() {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func addValueToBuffer(_ value: Element) {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
func replayBuffer<O: ObserverType>(_ observer: O) where O.E == Element {
|
||||
abstractMethod()
|
||||
rxAbstractMethod()
|
||||
}
|
||||
|
||||
override func on(_ event: Event<Element>) {
|
||||
|
Loading…
Reference in New Issue
Block a user