RxSwiftCommunity / RxRealm

RxSwift extension for RealmSwift's types
MIT License
1.15k stars 263 forks source link

Using again ReactiveCompatible extension on Realm type #171

Closed PhilippeCuvillier closed 2 years ago

PhilippeCuvillier commented 2 years ago

Starting from RxSwift 6.1 version, it is – again – possible to use the somehow standard rx attribute of ReactiveCompatible protocol extension on a non-class type like Realm. (https://github.com/ReactiveX/RxSwift/pull/2285)

This would again allow users of RxRealm to define their custom realm.rx.someCustomMethod() extension methods along with RxRealm ones. Ex:

extension Reactive where Base == Realm {
    func observeOptional<R: Object>(_ type: R.Type, identifier: String) -> Observable<R?> {
        Observable
            .collection(from: base.objects(R.self).filter(NSPredicate(format: "\(R.self.primaryKey()!) == %@", identifier)))
            .map { $0.first }
    }
}

Defining such extension is currently not possible as the ad hoc rx extension of RxRealm has a base attribute with private visibility, which prevents from using it in custom methods outside this pod.

rxswiftcommunity[bot] commented 2 years ago

Thanks a lot for contributing @PhilippeCuvillier! I've invited you to join the RxSwiftCommunity GitHub organization – no pressure to accept! If you'd like more information on what this means, check out our contributor guidelines and feel free to reach out with any questions.

Generated by :no_entry_sign: dangerJS

arshiacont commented 2 years ago

Any update on releasing this PR? Current production code is evading anyone rather than RxRealm to correctly define reactive extensions on Realm. Merging this PR would thus make this library compliant to how rx should be defined or extended.

arshiacont commented 2 years ago

@freak4pc this is the PR for #174 . It will make this pod/package standard with regards to other Rx extensions.

arshiacont commented 2 years ago

hmmm for some reason the Release Action has not been triggered.. any idea how the merged PR can appear in the Cocoapod repository or is it just a matter of time?! @freak4pc

arshiacont commented 2 years ago

PS: Thanks for merging... 🙏