-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
Added tests for subscribe #13
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit dacad4e:
|
Thanks so much for your interest and contribution. Here're some random/incomplete notes:
|
Thanks for your reply! I'm struggling to get my head around the exact workings of this lib, I'm not really familiar with proxies yet.
In the following example: how exactly does useProxy know that it should render on A and not re-render on B? Maybe we can use a similar technique to allow subscribing to Thanks for your time! |
I can understand how you struggle with these.
Between 1 and 2, we have snapshots that are pure objects (no proxies) They work totally differently. Theoretically, we could use the same technique in 2 to track read operation in 1, which means we use proxy-compare in 1. I'm not sure how far you read the code, but we use const listeners = new Set()
const notify = () => {
new Set(listners).forEach((listener) => {
listeners.delete(listener)
listener()
listners.add(listener)
})
} Does this work? If it does, it would be much simpler. |
@wilcoschoneveld Let me merge this PR as I'd like to add some tests in subscribe.test.tsx. |
Yep cool |
Hey! Thanks for the work on this library, I would like to contribute.
I have added tests for the
subscribe
function, and would also like to fix the non-working ones:When you call
subscribe
on a non-object property (count
in this case) it throws anCannot read property 'add' of undefined
error. I'm not quite sure how to go around fixing this, my guess is to do something like a createDeepProxy much earlier?When you change the state inside a subscription, it calls the subscription again leading to a
Maximum call stack size exceeded
exception. I think thisisDeepChanged
needs to be moved to intoproxy
in vanilla?Any pointers in the right direction? Thanks a lot!