- [ 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;
}