Skip to content

Commit

Permalink
Update PR template, small fix to netflify action path, reorganize pag…
Browse files Browse the repository at this point in the history
…e structure, update code comments
  • Loading branch information
MongoCaleb committed Aug 12, 2024
1 parent 2d45432 commit 4723800
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Add links to every SDK's pages where you got the SDK-specific information:

- [PAGE_NAME](https://www.mongodb.com/docs/atlas/device-sdks/LIVE-DOCS-LINK)

### Release Notes

<!--
- **Define Data Access Permissions**
- Data Access Role Examples: Update CRUD Permissions example screenshots and
copyable JSON
-->

### PR Author Checklist

Before requesting a review for your PR, please check these items:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/netflify-preview-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
id: build_page_links
run: |
new_links=""
base_link='https://deploy-preview-${{ github.event.number }}--docs-realm.netlify.app'
base_link='https://deploy-preview-${{ github.event.number }}--device-sdk.netlify.app'
changed_files=${{ steps.changed-files.outputs.all_changed_files }}
files=$(echo $changed_files | tr "," "\n")
for file in $files; do
Expand Down
3 changes: 3 additions & 0 deletions examples/dotnet/Examples/WorkWithRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,20 @@ NotificationCallbackDelegate<Person> notificationCallback

// Use one of these equivalent declarations to
// specify the fields you want to monitor for changes:

kpc = KeyPathsCollection.Of("Email", "Name");
kpc = new List<KeyPath> {"Email", "Name"};

// To get all notifications for top-level properties
// and 4 nested levels of properties, use the `Full`
// static value:

kpc = KeyPathsCollection.Full;

// To receive notifications for changes to the
// collection only and none of the properties,
// use the `Shallow` static value:

kpc = KeyPathsCollection.Shallow;

query.SubscribeForNotifications(notificationCallback, kpc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@

// Use one of these equivalent declarations to
// specify the fields you want to monitor for changes:

kpc = KeyPathsCollection.Of("Email", "Name");
kpc = new List<KeyPath> {"Email", "Name"};

// To get all notifications for top-level properties
// and 4 nested levels of properties, use the `Full`
// static value:

kpc = KeyPathsCollection.Full;

// To receive notifications for changes to the
// collection only and none of the properties,
// use the `Shallow` static value:

kpc = KeyPathsCollection.Shallow;

query.SubscribeForNotifications(notificationCallback, kpc);
61 changes: 32 additions & 29 deletions source/sdk/dotnet/react-to-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,27 @@ Realm emits an initial notification when a subscription is added. After the
initial notification, Realm delivers notifications asynchronously whenever a
write transaction adds, modifies, or removes objects in the collection.

To subscribe to collection notifications, call the
:dotnet-sdk:`SubscribeForNotifications <reference/Realms.CollectionExtensions.html#Realms_CollectionExtensions_SubscribeForNotifications__1_System_Collections_Generic_IDictionary_System_String___0__Realms_NotificationCallbackDelegate_System_Collections_Generic_KeyValuePair_System_String___0___>`
method. ``SubscribeForNotifications`` returns a subscription token which can be
disposed at any time to stop receiving notifications on the collection.
Notification ChangeSets
~~~~~~~~~~~~~~~~~~~~~~~

The following code shows how to observe a collection for changes.
The notification contains a :dotnet-sdk:`ChangeSet <reference/Realms.ChangeSet.html>`
with 6 properties:

.. literalinclude:: /examples/generated/dotnet/WorkWithRealm.snippet.collection-notifications.cs
:language: csharp
- ``DeletedIndices`` is an ``int[]`` that contains the indices of the objects that were
deleted.
- ``InsertedIndices`` is an ``int[]`` that contains the indices of the objects that were
inserted.
- ``ModifiedIndices`` is an ``int[]`` that contains the *old* indices of the objects
that were modified. These indices indicate the position of the modified objects
in the original collection before any deletions or insertions ocurred.
- ``NewModifiedIndices`` is an ``int[]`` that represents the same entries as the
``ModifiedIndices`` property, but the indices represent the new locations in the
collection after all changes have been accounted for.
- ``IsCleared`` is a boolean set to ``true`` when a collection has been cleared by
calling the ``Clear()`` method.
- ``Moved`` is an array of :dotnet-sdk:`ChangeSet.Move <reference/Realms.ChangeSet.Move.html>`
structs that contain the previous and new index of an object moved within the
collection.

.. important:: Order Matters

Expand All @@ -125,6 +137,19 @@ The following code shows how to observe a collection for changes.

Handling insertions before deletions may result in unexpected behavior.

Get Notified of All Collection Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To subscribe to collection notifications, call the
:dotnet-sdk:`SubscribeForNotifications <reference/Realms.CollectionExtensions.html#Realms_CollectionExtensions_SubscribeForNotifications__1_System_Collections_Generic_IDictionary_System_String___0__Realms_NotificationCallbackDelegate_System_Collections_Generic_KeyValuePair_System_String___0___>`
method. ``SubscribeForNotifications`` returns a subscription token which can be
disposed at any time to stop receiving notifications on the collection.

The following code shows how to observe a collection for changes.

.. literalinclude:: /examples/generated/dotnet/WorkWithRealm.snippet.collection-notifications.cs
:language: csharp

Limit Notifications
~~~~~~~~~~~~~~~~~~~

Expand All @@ -137,28 +162,6 @@ The following code shows how to observe specific fields:
.. literalinclude:: /examples/generated/dotnet/WorkWithRealm.snippet.field-notifications.cs
:language: csharp

Notification ChangeSet
~~~~~~~~~~~~~~~~~~~~~~

The notification contains a :dotnet-sdk:`ChangeSet <reference/Realms.ChangeSet.html>`
with 6 properties:

- ``DeletedIndices`` is an ``int[]`` that contains the indices of the objects that were
deleted.
- ``InsertedIndices`` is an ``int[]`` that contains the indices of the objects that were
inserted.
- ``ModifiedIndices`` is an ``int[]`` that contains the *old* indices of the objects
that were modified. These indices indicate the position of the modified objects
in the original collection before any deletions or insertions ocurred.
- ``NewModifiedIndices`` is an ``int[]`` that represents the same entries as the
``ModifiedIndices`` property, but the indices represent the new locations in the
collection after all changes have been accounted for.
- ``IsCleared`` is a boolean set to ``true`` when a collection has been cleared by
calling the ``Clear()`` method.
- ``Moved`` is an array of :dotnet-sdk:`ChangeSet.Move <reference/Realms.ChangeSet.Move.html>`
structs that contain the previous and new index of an object moved within the
collection.

.. _dotnet-unregister-a-change-listener:

Unregister a Change Listener
Expand Down

0 comments on commit 4723800

Please sign in to comment.