New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have you ever thought of making some adjustments to RxSwift? #165
Comments
Rx is fun! I think it would be inappropriate to have this as part of SwiftyUserDefaults, because there shouldn't be a forced dependency on RxSwift, but as an extension library — yeah! |
Extending on that, I'm facing issues because I'm using |
I think making Also @0x30 what about an Rx extension in https://github.com/RxSwiftCommunity/ ? |
Ok, I may not express it very clearly, I hope I can get a configuration similar to Moya. s.subspec "ReactiveSwift" do |ss|
ss.source_files = "Sources/ReactiveMoya/"
ss.dependency "Moya/Core"
ss.dependency "ReactiveSwift", "~> 5.0"
end
s.subspec "RxSwift" do |ss|
ss.source_files = "Sources/RxMoya/"
ss.dependency "Moya/Core"
ss.dependency "RxSwift", "~> 4.0"
end |
Aha! Well, this would require the |
This is how I started in my app during the v4.0 transition, btw: extension Reactive where Base: UserDefaults {
func observe<T: DefaultsSerializable>(key: DefaultsKey<T>, options: NSKeyValueObservingOptions = [.old, .new]) -> RxSwift.Observable<T.T?> {
return Observable.create { observer -> Disposable in
let token = self.base.observe(key: key, options: options) { update in
observer.onNext(update.newValue)
}
return Disposables.create {
token.dispose()
}
}
}
} |
is there an updated sample for v5? Edit: got it to work properly: extension DefaultsAdapter {
func observe<T: DefaultsSerializable>(_ key: DefaultsKey<T>,
options: NSKeyValueObservingOptions = [.old, .new]
) -> RxSwift.Observable<DefaultsObserver<T>.Update> where T == T.T {
Observable.create { observer in
let token = self.observe(key, options: options) { update in
observer.onNext(update)
}
return Disposables.create {
token.dispose()
}
}
}
func observe<T: DefaultsSerializable>(_ keyPath: KeyPath<KeyStore, DefaultsKey<T>>,
options: NSKeyValueObservingOptions = [.old, .new]
) -> RxSwift.Observable<DefaultsObserver<T>.Update> where T == T.T {
Observable.create { observer in
let token = self.observe(keyPath, options: options) { update in
observer.onNext(update)
}
return Disposables.create {
token.dispose()
}
}
}
} |
Have you ever thought of making some adjustments to RxSwift?
Like the following?
The text was updated successfully, but these errors were encountered: