Skip to content

Commit 8f328d5

Browse files
Update Swift LiveObjects documentation for apply-on-ACK
This mirrors the changes made for JavaScript in a4f5929, adapted for Swift now that the Swift SDK also applies operations on acknowledgement rather than on echo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ba0e44 commit 8f328d5

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/pages/docs/liveobjects/concepts/synchronization.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,19 @@ When a client publishes an operation, the operation is applied to its local obje
5757
</Aside>
5858

5959
<Aside data-type='important'>
60-
If you're also developing with the Swift or Java SDKs, note that they currently apply operations when [echoed](/docs/pub-sub/advanced#echo) back from the server rather than on acknowledgment. Apply-on-acknowledgment is coming soon to those SDKs.
60+
If you're also developing with the Java SDK, note that it currently applies operations when [echoed](/docs/pub-sub/advanced#echo) back from the server rather than on acknowledgment. Apply-on-acknowledgment is coming soon to the Java SDK.
6161
</Aside>
6262
</If>
63-
<If lang="swift,java">
63+
<If lang="swift">
64+
<Aside data-type='note'>
65+
When a client publishes an operation, the operation is applied to its local objects as soon as the operation is acknowledged by the Ably system. This means that when a mutation method returns, the operation has already been applied and you can immediately read the updated state.
66+
</Aside>
67+
68+
<Aside data-type='important'>
69+
If you're also developing with the Java SDK, note that it currently applies operations when [echoed](/docs/pub-sub/advanced#echo) back from the server rather than on acknowledgment. Apply-on-acknowledgment is coming soon to the Java SDK.
70+
</Aside>
71+
</If>
72+
<If lang="java">
6473
<Aside data-type='note'>
6574
Currently, when a client publishes an operation it is not immediately applied to its local objects. Instead, the client only applies the operation when the operation is [echoed](/docs/pub-sub/advanced#echo) back to the client.
6675
</Aside>

src/pages/docs/liveobjects/counter.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,16 @@ System.out.println("Counter value: " + counter.value());
302302
303303
You can subscribe to data updates on a counter to receive realtime changes made by you or other clients.
304304
305+
<If lang="swift">
306+
<Aside data-type='note'>
307+
`LiveCounter` mutation methods send operations to the Ably system and apply changes locally as soon as the operations are acknowledged. When a mutation method returns, the operation has been applied and you can immediately read the updated state. You will also be notified via subscription when the counter is updated.
308+
</Aside>
309+
</If>
310+
<If lang="java">
305311
<Aside data-type='note'>
306312
`LiveCounter` mutation methods do not directly modify the local counter state. Instead, they send the intended operation to the Ably system, and the change is applied only when the corresponding realtime operation is echoed back to the client. This means that the state retrieved immediately after a mutation may not reflect the latest updates yet. You will be notified via subscription when the counter is updated.
307313
</Aside>
314+
</If>
308315
309316
Subscribe to data updates on a counter using the `LiveCounter.subscribe()` method:
310317

src/pages/docs/liveobjects/map.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,16 @@ System.out.println("Value for my-key: " + map.get("my-key").getValue());
391391
392392
You can subscribe to data updates on a map to receive realtime changes made by you or other clients.
393393
394+
<If lang="swift">
395+
<Aside data-type='note'>
396+
`LiveMap` mutation methods send operations to the Ably system and apply changes locally as soon as the operations are acknowledged. When a mutation method returns, the operation has been applied and you can immediately read the updated state. You will also be notified via subscription when the map is updated.
397+
</Aside>
398+
</If>
399+
<If lang="java">
394400
<Aside data-type='note'>
395401
`LiveMap` mutation methods do not directly modify the local map state. Instead, they send the intended operation to the Ably system, and the change is applied only when the corresponding realtime operation is echoed back to the client. This means that the state retrieved immediately after a mutation may not reflect the latest updates yet. You will be notified via subscription when the map is updated.
396402
</Aside>
403+
</If>
397404
398405
Subscribe to data updates on a map using the `LiveMap.subscribe()` method:
399406

src/pages/docs/liveobjects/quickstart/swift.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ try await reactionsMap.remove(key: "like")
188188
</Code>
189189

190190
<Aside data-type='note'>
191-
Mutation methods (such as `LiveMap.set(key:value:)`, `LiveCounter.increment(amount:)`, etc.) do not directly modify the local object state. Instead, they send the intended operation to the Ably system, and the change is applied only when the corresponding realtime operation is echoed back to the client. This means that the state retrieved immediately after a mutation may not reflect the latest updates yet. You will be notified via subscription when the object is updated.
191+
Mutation methods (such as `LiveMap.set(key:value:)`, `LiveCounter.increment(amount:)`, etc.) send operations to the Ably system and apply changes locally as soon as the operations are acknowledged. When a mutation method returns, the operation has been applied and you can immediately read the updated state. You will also be notified via subscription when the object is updated.
192192
</Aside>
193193

194194
## Next steps <a id="step-8"/>

0 commit comments

Comments
 (0)