Skip to content
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

Support wildcards in keypath notifications #7125

Closed
cmelchior opened this issue Nov 10, 2023 · 0 comments · Fixed by #7163
Closed

Support wildcards in keypath notifications #7125

cmelchior opened this issue Nov 10, 2023 · 0 comments · Fixed by #7163
Assignees

Comments

@cmelchior
Copy link
Contributor

This is an extension to #7087

Users of the SDK are currently using an API that looks something like this

val keypaths = listOf("name", "age", "child", "child.age", "child.name")
results.add_notification_callback(keypaths, callback)

For a limited number of properties, this is fine, but it quickly becomes unmanageable for larger object graphs. For this reason, it would be nice if the keypath method introduced in https://github.com/realm/realm-core/pull/7087/files#diff-26d19337fc5c7d539cf862de4f09e38ea8b514402b48349adb3713832aee5518R50, would be able to handle * as a wildcard property and automatically expand any object references or object lists/sets/maps.

E.g. given this object graph:

class Person: RealmObject {
  var name: String
  var age: Int
  var children: RealmList<Child>
}

class Child: RealmObject {
  var name: String
  var favoritePet: Pet?
}

class Pet: RealmObject {
  var name: String
  var type: String
}

You could register a wildcard keypath like *.*.* which would be equal to listOf("name", "age", "children", "children.name", "children.favoritePet", "children.favoritePet.name", "children.favoritePet.type")

Wildcards should only expand valid paths and ignore an expansion that isn't valid, i.e. children.*.type would only match children.favoritePet.type because it would be the only correct path matching the expanded path.

As a sidenote, the current implementation in the notifier is equivalent to *.*.*.* since we only detect changes 4 nested levels down.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants