From 86e4c64610106f610c9b7900e23bedbbf985dcc8 Mon Sep 17 00:00:00 2001 From: Hunter Johnston Date: Thu, 25 Apr 2024 18:21:20 -0400 Subject: [PATCH] update docs --- sites/docs/content/functions/box.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sites/docs/content/functions/box.md b/sites/docs/content/functions/box.md index 2a73c1c4..a8c34e8a 100644 --- a/sites/docs/content/functions/box.md +++ b/sites/docs/content/functions/box.md @@ -132,6 +132,20 @@ flat.increment(); console.log(flat.count); // 2 ``` +### `box.readonly` + +Creates a readonly box from a writable box that remains in sync with the original box. + +```ts +const count = box(1) +const readonlyCount = box.readonly(count) +console.log(readonlyCount.value) // 1 +count.value++ +console.log(readonlyCount.value) // 2 + +readonlyCount.value = 3 // Error: Cannot assign to read only property 'value' of object +``` + ### `box.isBox` Checks if a value is a `Box`.