Skip to content

Instantly share code, notes, and snippets.

@zzdjk6
Created December 4, 2017 02:14
Show Gist options
  • Save zzdjk6/82bc7f135dd765cfd0c155401a192fb7 to your computer and use it in GitHub Desktop.
Save zzdjk6/82bc7f135dd765cfd0c155401a192fb7 to your computer and use it in GitHub Desktop.
Compatible Layer: Commonly used Disposable Types in RxSwift 2.x
public class AnonymousDisposable: Cancelable {
public func dispose() {
self.disposableImpl.dispose()
}
public var isDisposed: Bool { return self.disposableImpl.isDisposed }
private var disposableImpl: Cancelable
public init(_ closure: @escaping () -> ()) {
self.disposableImpl = Disposables.create {
closure()
}
}
}
public class NopDisposable: Disposable {
public func dispose() {
// do nothing
}
/// Singleton
public static let instance: Disposable = Disposables.create()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment