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

Timeline / proposal for extensions? #506

Open
matthew-dean opened this issue Apr 10, 2023 · 8 comments
Open

Timeline / proposal for extensions? #506

matthew-dean opened this issue Apr 10, 2023 · 8 comments

Comments

@matthew-dean
Copy link

This repo has a lot of really great & valuable extensions that could limit boilerplate in a lot of userland reactive libraries (specifically / let & const decorators).

Is there a separate proposal that tracks those?

@pzuraq
Copy link
Collaborator

pzuraq commented Apr 10, 2023

Parameter decorators are currently in stage 1, being explored here: https://github.com/tc39/proposal-class-method-parameter-decorators

Function decorators are the other major candidate that seems to have enough momentum that they could be included in the language at some point. let/const decorators were discussed before in the plenary briefly, but there was not much appetite for them. We would basically be adding a new getter/setter mechanism to scopes in the language, which is a huge amount of complexity to add, and would make many types of optimizations very difficult.

Personally I'm committed to seeing this proposal and the metadata proposal through the process, and I may try to help with Function decorators after that (given I have the time and energy), but I can't say which, if any, of the proposed extensions will be pursued beyond that.

@matthew-dean
Copy link
Author

matthew-dean commented Apr 10, 2023

@pzuraq I think one frustrating thing as a developer is that, had the with keyword not been explicitly forbidden in strict mode, and had ES6 modules not extended strict mode, then reactive variables would have been possible using with + a Proxy object today, without any language additions.

Like, I get that with could be a possible footgun, but it's frustrating that JavaScript used to have features that would have allowed getters / setters on plain variables, and no longer does. I'm just hoping this feature comes back to JavaScript again in the future in a cleaner way.

@ljharb
Copy link
Member

ljharb commented Apr 10, 2023

"Reactive variables" are something that nonzero people consider to be a footgun, myself included.

@matthew-dean
Copy link
Author

@ljharb 🤷‍♂️ Possibly. But it makes UI state updates trivially easy. In the old days, you had to track each and every side effect, and patch manually, or just track nothing and destructively patch everything. And without operator overloading in JavaScript, at least allowing getter / setter on simple assignment / reference would simplify so much real-world code.

@pzuraq
Copy link
Collaborator

pzuraq commented Apr 12, 2023

@matthew-dean doesn’t that just mean users have to define a class or object with accessors to intercept access to reactive values? Is the goal to enable something like the reactivity in Svelte’s reactive statements?

@justinfagnani
Copy link

Svelte reactivity isn't implementable even with reactive variables because Svelte also treats a module as an instantiable thing, like a class.

@pzuraq
Copy link
Collaborator

pzuraq commented Apr 12, 2023

@justinfagnani Yeah I was going to bring that up, I just am trying to understand the use cases before digging into potential issues, wanna make sure I’m not missing anything.

@errorx666
Copy link

errorx666 commented Apr 30, 2024

I definitely want to see function decorators as soon as possible. I tend to favor less object-oriented design patterns in JS.

Object literal and property decorators also interest me, as I use those more than classes.

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

No branches or pull requests

5 participants