diff --git a/source/includes/api-details/csharp/model-data/object-models-define-custom-setters-description.rst b/source/includes/api-details/csharp/model-data/object-models-define-custom-setters-description.rst new file mode 100644 index 0000000000..8ab3229f5b --- /dev/null +++ b/source/includes/api-details/csharp/model-data/object-models-define-custom-setters-description.rst @@ -0,0 +1,2 @@ +In the following code, the private ``email`` property is stored in the database, +but the public ``Email`` property, which provides validation, is not persisted. diff --git a/source/includes/sdk-examples/model-data/define-custom-setters.rst b/source/includes/sdk-examples/model-data/define-custom-setters.rst new file mode 100644 index 0000000000..7818169cc5 --- /dev/null +++ b/source/includes/sdk-examples/model-data/define-custom-setters.rst @@ -0,0 +1,71 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Objects.snippet.custom-setter.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.kt + :language: kotlin + :copyable: false + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/sdk/model-data/object-models.txt b/source/sdk/model-data/object-models.txt index 590fd3fa09..f0cb82ca06 100644 --- a/source/sdk/model-data/object-models.txt +++ b/source/sdk/model-data/object-models.txt @@ -1076,6 +1076,55 @@ first access, so will never be nil. .. include:: /includes/sdk-examples/model-data/define-default-value-for-property.rst +.. _sdks-custom-setters: + +Define Custom Setters +~~~~~~~~~~~~~~~~~~~~~ + +For some platforms and languages, the idiomatic developer experience involves +defining custom setters. The SDK does not directly persist properties using +custom setters. Instead, you can store the property value in a private property, +and then map that value to a public property that uses the custom setter. + +The SDK stores the private property, while you modify its value through the +public property. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/model-data/object-models-define-custom-setters-description.rst + + .. tab:: + :tabid: dart + + .. tab:: + :tabid: java + + .. tab:: + :tabid: java-kotlin + + .. tab:: + :tabid: javascript + + .. tab:: + :tabid: kotlin + + .. tab:: + :tabid: objectivec + + .. tab:: + :tabid: swift + + .. tab:: + :tabid: typescript + +.. include:: /includes/sdk-examples/model-data/define-custom-setters.rst + .. _sdks-model-unstructured-data: Model Unstructured Data @@ -1252,7 +1301,16 @@ a projection to make data available in a specific form, but persist it in a different form. For example, you might want to work with persisted data in a different way in -a view model or based on certain business logic. +a view model or based on certain business logic. This simplifies using and +testing SDK objects in your application. + +With projection, you can use a subset of your object's properties directly in +the UI, or transform them. When you use a projection for this, you get all the +benefits of the SDK's live objects: + +- The class-projected object live updates +- You can observe it for changes +- You can apply changes directly to the properties in write transactions Projection is currently only available in the Swift SDK. diff --git a/source/sdk/model-data/property-types.txt b/source/sdk/model-data/property-types.txt index 1f14dbaded..50b82a1107 100644 --- a/source/sdk/model-data/property-types.txt +++ b/source/sdk/model-data/property-types.txt @@ -80,3 +80,18 @@ Define a Set Property Define a Dictionary Property ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _sdks-relationship-property-types: + +Relationship Property Types +--------------------------- + +.. _sdks-other-property-types: + +Other Property Types +-------------------- + +.. _sdks-enum-property: + +Define an Enum Property +~~~~~~~~~~~~~~~~~~~~~~~