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

[RRFC] Add additional decorators to help observe property changes and create event properties #28

Open
sorvell opened this issue Sep 18, 2023 · 0 comments

Comments

@sorvell
Copy link
Member

sorvell commented Sep 18, 2023

  • [ X] I searched for an existing RRFC which might be relevant to my RRFC

Motivation

Lit has proven that declarative setup via decorators is exceptionally convenient and useful. Additional decorators could be explored in a lit-labs package for potential inclusion based on feedback. Two obvious candidates are @observe and @event.

The @observe decorator would be used on a class member function which would be called when the noted propery changes.

The @event decorator would be used on a property intended to behave like a platform event property, e.g. onclick.

Example

A simple @observe decorator is prototyped here.

A simple @event decorator is prototyped here.

class MyElement extends LitElement {

  @property()
  foo = 'foo';

  @observe('foo')
  #fooChanged(value, old, name) {...}

  @event('hiya')
  onHiya?: EventListener;
}
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

1 participant