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

Key path filtered notifications in Object and Collection #6310

Merged
merged 28 commits into from
Dec 19, 2023

Conversation

kraenhansen
Copy link
Member

What, How & Why?

This closes #6285 by exposing an optional third argument to the addListener methods.
This also updates Core to v13.24.0 to pull in the new APIs that got added to the spec.yml and depends on one additional change that hasn't been merged and released yet.

NOTE: Because of 30d99c0 adding a listener twice, will start throwing instead of being a no-op. We had tests for this, but it wasn't explicitly documented, so technically not a breaking change to the documented API, but it still might result in runtime errors in some consuming code-bases.

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 📝 Update COMPATIBILITY.md
  • 🚦 Tests (on Object, Results and Dictionary - missing tests on List and Set, but they hit the same code)
  • 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • 📱 Check the React Native/other sample apps work if necessary
  • 💥 Breaking label has been applied or is not necessary

Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions. Otherwise, looks good 👍🏼

integration-tests/tests/src/setup-globals.ts Show resolved Hide resolved
packages/realm/package.json Outdated Show resolved Hide resolved
packages/realm/src/Collection.ts Show resolved Hide resolved
packages/realm/src/Collection.ts Show resolved Hide resolved
Copy link
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome getting this in so it can be tried out. Left some ideas and suggestions 👍

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
[
EMPTY_OBJECT_CHANGESET,
() => {
// Updating the age to 42 will ensure the object doesn't leave the results
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Updating the age to 42 will ensure the object doesn't leave the results
// Updating the age will ensure the listener is not triggered by a non-specified key path.

integration-tests/tests/src/tests/observable.ts Outdated Show resolved Hide resolved
packages/realm/src/Object.ts Outdated Show resolved Hide resolved
@kraenhansen kraenhansen force-pushed the kh/key-path-filtered-notifications branch from d7fc197 to d3498ba Compare December 12, 2023 15:01
Copy link

coveralls-official bot commented Dec 12, 2023

Coverage Status

coverage: 85.841% (+0.3%) from 85.573%
when pulling 852122c on kh/key-path-filtered-notifications
into 7fec08b on main.

@kraenhansen kraenhansen force-pushed the kh/key-path-filtered-notifications branch from 9f8c7db to d687e74 Compare December 12, 2023 19:58
CHANGELOG.md Outdated Show resolved Hide resolved
@kraenhansen kraenhansen force-pushed the kh/key-path-filtered-notifications branch from 32a3760 to bacd09c Compare December 14, 2023 08:14
Copy link
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

integration-tests/tests/src/tests/observable.ts Outdated Show resolved Hide resolved
integration-tests/tests/src/tests/observable.ts Outdated Show resolved Hide resolved
packages/realm/src/Object.ts Show resolved Hide resolved
@kraenhansen kraenhansen force-pushed the kh/key-path-filtered-notifications branch from b46b689 to 852122c Compare December 19, 2023 13:19
@kraenhansen kraenhansen merged commit 4533925 into main Dec 19, 2023
33 checks passed
@kraenhansen kraenhansen deleted the kh/key-path-filtered-notifications branch December 19, 2023 15:23
bimusiek pushed a commit to bimusiek/realm-js that referenced this pull request Mar 14, 2024
)

* Pin Listeners to throwOnReAdd

* Adding key path filtering to Collection

* Tests WIP

* Show the entire diff when deep.equals fails

* Implemented key-path notifications for RealmObject

* Adding an entry to the changelog

* Passing key-paths through for Dictionary

* Adding dictionary tests

* Adding changelog entry about the dictionary fix

* Adding a note on the breaking change

* Apply suggestions from code review

Co-authored-by: LJ <[email protected]>

* Adding string overload to Object#addListener

* Adding @param doc strings

* Adding an example to the changelog and doc comments.

* Refactored to use a common "expectNotifications" function

* Moved keyPaths before changesAndActions

* Apply suggestions from code review

Co-authored-by: LJ <[email protected]>

* Adding a few more tests

* Adding a test using wildcard (*)

* Using key-path array of strings in tests again

* Adding multiple listeners with different key paths to verify that the union is indeed used

* Separated key-path tests into separate "it"s

* Update SDK unit tests

* Moved changelog entry from breaking changes to fixed

* Update CHANGELOG.md

* Updated doc comments

* Updated readd tests

* Updating a comment

---------

Co-authored-by: LJ <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key-path filtering when adding listeners to Collection and Object
4 participants