-
Notifications
You must be signed in to change notification settings - Fork 93
Remove KclProvider, replace its listener pattern with Preact Signals #9060
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d347a8e to
ed652e2
Compare
ed652e2 to
b8c5287
Compare
authored with codex, using previous two commits as examples.
We need it to wait until <App/> mounts to fire
… true Which broke the web app
b4be5ad to
a6ed618
Compare
| sourceRange?: SourceRange | ||
| selectionRanges: Selections | ||
| allowArrays?: boolean | ||
| code: string |
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.
Why is code a new parameter here instead of using kclManager.codeSignal.value?
Is it because it doesn't always use that but a new / modified code which is not yet in kclManager? If that's the case it's not a problem that the ast and variables are still being picked up from kclManager in this function?
andrewvarga
left a comment
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.
I've never used preact signals before but they seem very handy.
I agree that if we move more of our state to signals it can simplify accessing that state, and make the state less tightly coupled to React as well.
Maybe even move some state out of xstate to signals.
Do you see any downsides to using them so far?
Building upon #9058 (and #9056 by extension), towards #8880. We had this
KclContextProvidercomponent that gets around the difficulties with subscribing to updates to class properties by:useStateswhich receive their initial values from thekclManagerclass instance's property valuesuseEffectto wire up a series of "set" listener callbacks withinkclManagerthat are fired within the setters for each of those properties, which then sets the React state proxies inKclContextProvider, which consumers of the context can subscribe to reactively.So if we install
@preact/signals-coreand its corresponding bundler plugin for React we can get this sort of thing for far fewer lines of code. If you all like this I would like to propose it as a pattern we adopt, where state is kept outside of React in these classes and objects that interact, but React can subscribe to the "public" API of those state objects by wrapping them in Preact Signals.Users should experience no difference with this refactor.