Created
December 4, 2017 02:14
-
-
Save zzdjk6/82bc7f135dd765cfd0c155401a192fb7 to your computer and use it in GitHub Desktop.
Compatible Layer: Commonly used Disposable Types in RxSwift 2.x
This file contains hidden or 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
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