Home rxswift nodisposable
Post
Cancel

rxswift nodisposable

NoDisposable

类似于telegramSwiftSignalKit中的EmptyDisposable

1
2
3
4
5
6
7
8
9
10
11
12
private struct NopDisposable : Disposable {
 
    fileprivate static let noOp: Disposable = NopDisposable()
    
    private init() {
        
    }
    
    /// Does nothing.
    public func dispose() {
    }
}
1
2
3
4
5
6
7
8
extension Disposables {
    /**
     Creates a disposable that does nothing on disposal.
     */
    static public func create() -> Disposable {
        return NopDisposable.noOp
    }
}

Disposable见另一篇

注:文中源码来自RxSwift

This post is licensed under CC BY 4.0 by the author.