-
Notifications
You must be signed in to change notification settings - Fork 0
spike: some experiments on use(obserable) - very rough #2
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
Conversation
For more context, see https://coolsoftware.dev/blog/a-path-towards-observable-values-in-react/ |
The diff looks bigger than it is because my editor formatted it, but you'll wanna look for the |
@@ -1191,13 +1168,29 @@ function use<T>(usable: Usable<T>): T { | |||
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) { | |||
const context: ReactContext<T> = (usable: any); | |||
return readContext(context); | |||
} else if (usable.$$typeof === 'REACT_OBSERVABLE_TYPE') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the beginning of the relevant changes
In 7c40b75, I just started logging the name value in Running tests for default (experimental)...
console.log
name First
at Sync (packages/react-reconciler/src/__tests__/ReactUseObservable-test.js:97:15)
console.log
name Second
at Sync (packages/react-reconciler/src/__tests__/ReactUseObservable-test.js:97:15) I also changed the names to So it seems like the observability is working, but I'm making a silly mistake in the test here. |
Hey @rcharmeyer - can you say more about what you mean here? |
Nevermind, I was just hallucinating a use case that doesn't exist. |
Haha I 100% understand. The last few days have been full of that for me. Thanks for taking a look anyway! If you know more about React internals than me, I'd appreciate any insights you have. |
Heyo, I think I got it. Since this hacky code doesn't know anything about So now the callback calls But, it makes this demo minimally functional. Run |
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you! |
Extremely rough, actual implementation code that isn't even close to working.
Run test: