diff --git a/docs/usage/client.md b/docs/usage/client.md index 6cc2183..a87ad0b 100644 --- a/docs/usage/client.md +++ b/docs/usage/client.md @@ -1,14 +1,15 @@ -A client connects their `YDoc` through a [WebsocketProvider](../reference/WebSocket_provider.md). +A client connects their `Doc` through a [WebsocketProvider](../reference/WebSocket_provider.md). Here is a code example using the [websockets](https://websockets.readthedocs.io) library: ```py import asyncio -import y_py as Y from websockets import connect +from pycrdt import Doc, Map from pycrdt_websocket import WebsocketProvider async def client(): - ydoc = Y.YDoc() + ydoc = Doc() + ymap = ydoc.get("map", type=Map) async with ( connect("ws://localhost:1234/my-roomname") as websocket, WebsocketProvider(ydoc, websocket), @@ -16,9 +17,7 @@ async def client(): # Changes to remote ydoc are applied to local ydoc. # Changes to local ydoc are sent over the WebSocket and # broadcast to all clients. - ymap = ydoc.get_map("map") - with ydoc.begin_transaction() as t: - ymap.set(t, "key", "value") + ymap["key"] = "value" await asyncio.Future() # run forever