RxRealm icon indicating copy to clipboard operation
RxRealm copied to clipboard

[Feature Request] Support Key Path Change Listener

Open mtgto opened this issue 4 years ago • 1 comments

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)
    }
  })

mtgto avatar Sep 19 '21 10:09 mtgto

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.

JoeMatt avatar Jan 22 '22 02:01 JoeMatt