From 5937ee48a187bbe0b455f84989bdb69cefa1d9c4 Mon Sep 17 00:00:00 2001 From: brunnerh Date: Fri, 11 Oct 2024 18:27:17 +0200 Subject: [PATCH 1/2] docs: Reference `svelte/reactivity` from `$state`. --- documentation/docs/03-runes/01-state.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/03-runes/01-state.md b/documentation/docs/03-runes/01-state.md index 1ab89fa2398e..badea8530476 100644 --- a/documentation/docs/03-runes/01-state.md +++ b/documentation/docs/03-runes/01-state.md @@ -60,7 +60,7 @@ Objects and arrays are made deeply reactive by wrapping them with [`Proxies`](ht ``` -> [!NOTE] Only POJOs (plain old JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone +> [!NOTE] Only POJOs (plain old JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone. For some built-ins like `Set` and `Map`, there are reactive implementations that can be imported from `svelte/reactivity`. ## `$state.raw` From d4f33d2b4878acaf6f64fa17e85ad5f1b891f55f Mon Sep 17 00:00:00 2001 From: brunnerh Date: Wed, 23 Oct 2024 02:58:35 +0200 Subject: [PATCH 2/2] add reference to `svelte/reactivity` again --- documentation/docs/02-runes/02-$state.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/docs/02-runes/02-$state.md b/documentation/docs/02-runes/02-$state.md index 5c942c0444da..e8213d3cf4a8 100644 --- a/documentation/docs/02-runes/02-$state.md +++ b/documentation/docs/02-runes/02-$state.md @@ -20,6 +20,8 @@ Unlike other frameworks you may have encountered, there is no API for interactin If `$state` is used with an array or a simple object, the result is a deeply reactive _state proxy_. [Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) allow Svelte to run code when you read or write properties, including via methods like `array.push(...)`, triggering granular updates. +> [!NOTE] Classes like `Set` and `Map` will not be proxied, but Svelte provides reactive implementations for various built-ins like these that can be imported from [`svelte/reactivity`](./svelte-reactivity). + State is proxified recursively until Svelte finds something other than an array or simple object. In a case like this... ```js