RxSwiftCommunity / RxRealm

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

[Feature Request] Support Key Path Change Listener #172

Open mtgto opened 2 years ago

mtgto commented 2 years ago

Since Realm 10.12.0, function observe can receive keyPaths parameter, which can select object properties object or collection. https://docs.mongodb.com/realm/sdk/ios/examples/react-to-changes/#register-a-key-path-change-listener

I want to write code with RxRealm like below 😍 :

Observable.changeset(from: dogs, keyPaths: ["favoriteToy", "age"])
  .subscribe(onNext: { results, changes in
    if let changes = changes {
      // it's an update
      print(results)
      print("deleted: \(changes.deleted)")
      print("inserted: \(changes.inserted)")
      print("updated: \(changes.updated)")
    } else {
      // it's the initial data
      print(results)
    }
  })
JoeMatt commented 2 years ago

I like this idea. I use keypaths a lot. Would prefer it there was KeyPath usage though other than strigs, if it's possible. I hope to look into this but if anyone wants to work on this, I will review any PRs.