Last active
November 11, 2019 08:43
-
-
Save mono0926/78bf126d9bd887276793410890c44e38 to your computer and use it in GitHub Desktop.
This file contains 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
struct DisposableWrapper: Disposable { | |
private let disposable: Disposable | |
init(disposable: Disposable) { | |
self.disposable = disposable | |
} | |
func dispose() { | |
disposable.dispose() | |
} | |
} | |
public extension Observable { | |
public func `do`(onDisposed: @escaping () -> ()) -> Observable { | |
return Observable.using({ | |
return DisposableWrapper(disposable: Disposables.create(with: onDisposed)) | |
}, observableFactory: { _ -> Observable in | |
return self | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DisposableWrapper
でくるまないと、以下のコンパイルエラー(´・︵・`)