Skip to content

Commit 92a7b75

Browse files
committed
chore: add missing code to model-client v2 docs
1 parent 43355c0 commit 92a7b75

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/global/modules/core/pages/howto/usage-model-client-v2.adoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ val client = ModelClientV2.builder()
3838

3939
Nearly all operations are interfacing with a remote repository, consequently most operations in the client are https://kotlinlang.org/docs/composing-suspending-functions.html[suspending functions^].
4040
As a result, we need to use https://kotlinlang.org/docs/coroutines-basics.html[Kotlin Coroutines^] to execute these functions.
41-
To initialize the client, we can call:
41+
To initialize the client, we can call (we assume coroutine execution in all following code blocks):
4242

4343
[source, kotlin]
4444
--
@@ -52,7 +52,18 @@ runBlocking(CoroutineScope(Dispatchers.Default).coroutineContext){
5252
Afterward, we create a repository and replicate it locally into a `ReplicatedModel`.
5353
This data structure automatically synchronizes its content with the remote.
5454
We can consequently assume that its data is always correct and up-to-date.
55-
To ensure this, we need to use read and write transactions whenever we interact with the content, e.g. by adding a new child (we assume coroutine execution):
55+
56+
[source, kotlin]
57+
--
58+
val myRepoId: RepositoryId = RepositoryId("myRepository")
59+
modelClientV2.initRepository(myRepoId)
60+
61+
val myBranchReference: BranchReference = BranchReference(repositoryId = myRepoId, branchName = RepositoryId.DEFAULT_BRANCH)
62+
val replicatedModel: ReplicatedModel = modelClientV2.getReplicatedModel(myBranchReference)
63+
replicatedModel.start()
64+
--
65+
66+
To ensure that read and write are executed correctly, we need to use read and write transactions whenever we interact with the content, e.g. by adding a new child:
5667

5768
[source, kotlin]
5869
--

0 commit comments

Comments
 (0)