lit-html-workshop icon indicating copy to clipboard operation
lit-html-workshop copied to clipboard

React version of data up

Open chiefcll opened this issue 5 years ago • 2 comments

This is a simpler way to change the read property that follows closer to how React does it. Some folks taking this workshop might relate to this approach better. Good to show off both.

chiefcll avatar Apr 01 '19 19:04 chiefcll

Thanks for the contribution!

I agree it's good to show for comparison, but I'm not sure if there is a clear benefit of using a callback VS an event so I'm a bit hesitant to show it to people who are just getting standard.

I've been working with web components for a long time and always used events. Events are used by native elements as well, have a larger API surface and can benefit from the dom hierarchy (bubbling / composed events etc.).

LarsDenBakker avatar Apr 01 '19 20:04 LarsDenBakker

Not sure how I feel about this, first reason being that onRead: { type: Function }, is not really a thing (this'll just default to String because LitElement doesn't do anything with Function, unless you write your own converter, in which case you should use onRead: { converter: someConverter } instead.)

The second being that web component best practices recommend to use events. If you dont intend to publish your components, and only use them internally I guess you could do this, but im not sure if we should go out of our way just to be closer to a React-way of doing things.

thepassle avatar Apr 01 '19 20:04 thepassle