Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the question from #101 to the Q&A section: What is the relationship / how different from proxies? #102

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

NullVoxPopuli
Copy link
Collaborator

Tries to answer: #101

@@ -612,6 +612,10 @@ Note: untrack doesn't get you out of the `notifying` state, which is maintained

**A**: Signals can form an efficient basis for store-like state management abstractions. A common pattern found in multiple frameworks is an object based on a Proxy which internally represents properties using Signals, e.g., [Vue `reactive()`](https://vuejs.org/api/reactivity-core.html#reactive), or [Solid stores](https://docs.solidjs.com/concepts/stores). These systems enable flexible grouping of state at the right level of abstraction for the particular application.

**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).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this illustrates the answer to the question. Why is Proxy wrapping an object not like a Signal? I'd argue Proxy is very useful for listening to object changes which looks like what Signal is doing. What isn't reactive1 about the following?

function doit() {...}

const proxy = new Proxy({}, {
  set(target, name, val) {
    if (name === 'doit') {
      doit(val)
    }
  }
});

proxy.doit = true

Footnotes

  1. I assume that the word "reactive" means something more than responds to change, but that isn't clear from the readme either.

Copy link
Member

@littledan littledan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start which I will land, but I think we will need a slightly more involved explanation.

@littledan littledan merged commit b752a89 into main Apr 1, 2024
3 checks passed
@littledan littledan deleted the docs-gh-101 branch April 1, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants