Skip to content

Instantly share code, notes, and snippets.

@mono0926
Last active November 11, 2019 08:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0926/78bf126d9bd887276793410890c44e38 to your computer and use it in GitHub Desktop.
Save mono0926/78bf126d9bd887276793410890c44e38 to your computer and use it in GitHub Desktop.
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
})
}
}
@mono0926
Copy link
Author

DisposableWrapper でくるまないと、以下のコンパイルエラー(´・︵・`)

Cannot convert value of type '() -> Disposable' to expected argument type '() -> _'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment