-
Notifications
You must be signed in to change notification settings - Fork 90
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
RDART-969: Keypath filtering on collections #1714
Conversation
@nielsenko |
Pull Request Test Coverage Report for Build 9477711446Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
…th-new' into fp/collection-keypath-new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look mostly good to me. Most of my comments are more suggestions, but the the one about import 'dart:ffi';
is a blocker 😄
CHANGELOG.md
Outdated
PR [#1713](https://github.com/realm/realm-dart/pull/1713)). This does **not** imply that realm works on web! | ||
for web without breaking compilation. (Issue [#1374](https://github.com/realm/realm-dart/issues/1374)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, sorry, I messed up the conflict it seems 🤦
/// Allows listening for changes when the contents of this collection changes. | ||
Stream<RealmListChanges<T>> get changes; | ||
|
||
/// Allows listening for changes when the contents of this collection changes on one of the provided [keyPaths]. | ||
Stream<RealmListChanges<T>> changesFor([List<String>? keyPaths]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a little late in the game... but since changesFor
only makes sense for collections of realm objects we could make it an extension method like:
extension ListOfRealmObjectsEx<T extends RealmObject> extends RealmList<T> {
Stream<RealmListChanges<T>> changesFor([List<String>? keyPaths]);
}
That way it becomes a compile error to try to call changesFor on RealmList<int>
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would actually make sense.
The only "issue" I see is that now changes
is defined as changesFor(null)
to avoid repetitions.
If we move changesFor
to an extension method then we'd need to have some duplication (admittedly not a biggie though). It also seems Dart does not have protected methods, so I don't know if I can go around this with some other language constructs. Any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make a private _changesFor
that both the changesFor
extension method, and changes
member delegates to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking something like that. In my mind it sounded uglier than it would probably be, I'll give it a try 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it in the last commit
packages/realm_dart/lib/src/map.dart
Outdated
@@ -33,6 +33,9 @@ abstract class RealmMap<T extends Object?> with RealmEntity implements MapBase<S | |||
|
|||
/// Allows listening for changes when the contents of this collection changes. | |||
Stream<RealmMapChanges<T>> get changes; | |||
|
|||
/// Allows listening for changes when the contents of this collection changes on one of the provided [keyPaths]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we spend some time explaining the difference between null
and []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more explanation on the extension method
@nielsenko I think I've addressed all the comments. We have some inconsistencies with naming:
Some other considerations (that probably require some work):
|
In my opinion..
Going forward we should try to reduce the use of realm prefix to where it is needed. This means only on public facing classes, that are likely to collide with other class names (
It should just be
it should just be
I'm a bit reluctant on this. For each handle, there is the interface, and two implementations.. I would prefer not to suffix the implementations with
The current C-api don't really give us much benefit, but yes. However, let us land this PR as is, and get started on the weekend 😄 .. we can always address this later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work 👍
I'll merge this as soon as the CI agrees |
This PR adds support for keypath filtering on collections
TODO: