From edeee29764c4c75d4d423850936a26930dbf28b4 Mon Sep 17 00:00:00 2001 From: axolotl <87679354+TheCommieAxolotl@users.noreply.github.com> Date: Thu, 4 Apr 2024 07:59:31 +1100 Subject: [PATCH 1/2] update answer to Proxy differences question --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c3d196b..81a8a21 100644 --- a/README.md +++ b/README.md @@ -622,7 +622,12 @@ Note: untrack doesn't get you out of the `notifying` state, which is maintained **Q**: What are Signals offering that `Proxy` doesn't currently handle? -**A**: Proxies must wrap some object. Proxies, by themselves, are not all that useful, but can't be used to create reactive-versions of Map, Set, Object, Array, etc. See Prior Implementations [tracked-built-ins](https://github.com/tracked-tools/tracked-built-ins/tree/master/addon/src/-private). +**A**: Proxies must wrap some object. They cannot be used to observe updates to primitive values such as numbers, strings, or symbols. +See Prior Implementations [tracked-built-ins](https://github.com/tracked-tools/tracked-built-ins/tree/master/addon/src/-private), [discussion](https://github.com/proposal-signals/proposal-signals/issues/101#issuecomment-2029802574). The following is valid for a Signal, but not for a Proxy: +```js +new Proxy(0, { ... }) // TypeError: Cannot create proxy with a non-object as target or handler +new Signal.State(0); // Perfectly valid +``` #### How do Signals work? From 888c40c0349d4596e09559cce0bbc4a3cb8ddfa6 Mon Sep 17 00:00:00 2001 From: axolotl <87679354+TheCommieAxolotl@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:56:41 +1100 Subject: [PATCH 2/2] update Proxy phrasing Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81a8a21..2b9a6f1 100644 --- a/README.md +++ b/README.md @@ -622,7 +622,7 @@ Note: untrack doesn't get you out of the `notifying` state, which is maintained **Q**: What are Signals offering that `Proxy` doesn't currently handle? -**A**: Proxies must wrap some object. They cannot be used to observe updates to primitive values such as numbers, strings, or symbols. +**A**: Proxies must wrap some object. They cannot be used to intercept property access/assignment to primitive values such as numbers, strings, or symbols. See Prior Implementations [tracked-built-ins](https://github.com/tracked-tools/tracked-built-ins/tree/master/addon/src/-private), [discussion](https://github.com/proposal-signals/proposal-signals/issues/101#issuecomment-2029802574). The following is valid for a Signal, but not for a Proxy: ```js new Proxy(0, { ... }) // TypeError: Cannot create proxy with a non-object as target or handler