Skip to content

Commit

Permalink
Remove notification example and snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed Aug 9, 2023
1 parent 1f9d25e commit fbb780e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 54 deletions.

This file was deleted.

24 changes: 16 additions & 8 deletions source/sdk/kotlin/realm-database/crud/create.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,13 @@ To persist a new object to a realm:
You can also upsert into a realm using specific criteria. See
:ref:`Upsert a Realm Object <kotlin-upsert-an-object>`.

Create an Embedded Object
~~~~~~~~~~~~~~~~~~~~~~~~~
Create a Collection
-------------------

To create an :ref:`embedded object <kotlin-embedded-objects>`, assign an
instance of the
`EmbeddedRealmObject <{+kotlin-local-prefix+}io.realm.kotlin.types/-embedded-realm-object/index.html>`__
to a parent object's property:
You can create ``RealmList``, ``RealmSet``, or ``RealmMap`` collections.

.. literalinclude:: /examples/generated/kotlin/DataTypesTest.snippet.create-embedded-object.kt
:language: kotlin
You can also register a notification handler to listen for changes to a collection. For more information, see
:ref:`React To Changes <kotlin-realm-list-change-listener>`.

Create an Object with a RealmSet Property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -117,6 +114,17 @@ For more information about defining a dictionary property, refer to
.. literalinclude:: /examples/generated/kotlin/CreateTest.snippet.percent-encode-disallowed-characters.kt
:language: kotlin

Create an Embedded Object
-------------------------

To create an :ref:`embedded object <kotlin-embedded-objects>`, assign an
instance of the
`EmbeddedRealmObject <{+kotlin-local-prefix+}io.realm.kotlin.types/-embedded-realm-object/index.html>`__
to a parent object's property:

.. literalinclude:: /examples/generated/kotlin/DataTypesTest.snippet.create-embedded-object.kt
:language: kotlin

.. _kotlin-create-asymmetric-object:

Create an Asymmetric Object
Expand Down
8 changes: 2 additions & 6 deletions source/sdk/kotlin/realm-database/crud/delete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ Remove an Item from a RealmSet

To remove an item from a ``RealmSet``, pass the element you want to
delete to
`set.remove() <{+kotlin-local-prefix+}io.realm.kotlin.types/-realm-set/index.html#-1503494415%2FFunctions%2F-1651551339>`__.

In this example, we add
`set.remove() <{+kotlin-local-prefix+}io.realm.kotlin.types/-realm-set/index.html#-1503494415%2FFunctions%2F-1651551339>`__:

.. literalinclude:: /examples/generated/kotlin/SchemaTest.snippet.remove-item-from-set.kt
:language: kotlin
Expand All @@ -160,9 +158,7 @@ Remove Multiple Items from a RealmSet

To remove multiple items from a ``RealmSet``, pass the elements you want to
delete to
`set.removeAll() <{+kotlin-local-prefix+}io.realm.kotlin.types/-realm-set/index.html#430447804%2FFunctions%2F-1651551339>`__

In the following example, we delete the set of favorite snacks we created earlier:
`set.removeAll() <{+kotlin-local-prefix+}io.realm.kotlin.types/-realm-set/index.html#430447804%2FFunctions%2F-1651551339>`__:

.. literalinclude:: /examples/generated/kotlin/SchemaTest.snippet.remove-multiple-items-from-set.kt
:language: kotlin
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ when you :ref:`open the realm <kotlin-open-a-realm>`.
:language: kotlin
:emphasize-lines: 2


Define a Collection
-------------------

Expand Down Expand Up @@ -125,7 +126,7 @@ In the following example, we define a ``Frog`` schema with a

.. literalinclude:: /examples/generated/kotlin/SchemaTest.snippet.define-a-realm-set.kt
:language: kotlin

.. _kotlin-define-realm-dictionary-type:

Define a RealmDictionary/RealmMap
Expand All @@ -144,7 +145,6 @@ or ``EmbeddedRealmObject``, the value must be declared nullable.
.. literalinclude:: /examples/generated/kotlin/CreateTest.snippet.percent-encode-disallowed-characters.kt
:language: kotlin


.. _kotlin-define-embedded-object:

Define an Embedded Object
Expand Down
29 changes: 0 additions & 29 deletions source/sdk/kotlin/realm-database/schemas/supported-types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,6 @@ is a specialized
where every key is a string. A ``RealmMap`` is an associative array that
contains key-value pairs with unique keys.



Notifications
`````````````

You can register a notification handler on a ``RealmSet``. Realm notifies your
handler when the set changes. To register a change listener on a single
object, generate a ``Flow`` from the ``RealmSet`` with `asFlow()
<{+kotlin-local-prefix+}io.realm.kotlin.types/-realm-list/as-flow.html>`__.
Next, use the ``collect()`` method to handle events on that ``Flow``. The ``Flow``
emits an `initialSet()
<{+kotlin-local-prefix+}io.realm.kotlin.notifications/-initial-set/index.html>`__
once subscribed and an `updatedSet()
<{+kotlin-local-prefix+}io.realm.kotlin.notifications/-updated-set/index.html>`__
on change.

In the following example, we react to changes on the ``favoriteSnacks`` set of our ``Frog`` object.

.. literalinclude:: /examples/generated/kotlin/SchemaTest.snippet.react-to-changes-from-the-set.kt
:language: kotlin

The ``Flow`` runs indefinitely until you `cancel the enclosing coroutine
<https://kotlinlang.org/docs/cancellation-and-timeouts.html>`__ or until you
delete the parent object.

.. literalinclude:: /examples/generated/kotlin/QuickStartTest.snippet.quick-start-unsubscribe-to-changes.kt
:language: kotlin


.. _kotlin-additional-types:

Additional Supported Data Types
Expand Down

0 comments on commit fbb780e

Please sign in to comment.