Closed kristianmandrup closed 5 years ago
Sounds cool. Can you get me some links/docs about defining a Polymer component as a JavaScript class?
Try searching Polymer ES2015 recipe or look for polymer starter kit plus ;) Also a recent talk at Google Polymer Conference, Amsterdam by Eric Bidel covering this.
Polymer element: Lifecycle and callbacks
https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html
You can see a class example here:
class MyGreeting {
beforeRegister() {
this.is = 'my-greeting';
this.properties = {
greeting: {
type: String,
value: 'Welcome!',
notify: true
}
};
}
}
Polymer(MyGreeting);
Cool. I'll dig into it later :)
Looks like this project/pattern could be easily ported to Polymer web components, which also have component states and life-cycle event handlers, props etc. How about that? Recently Polymer now supports ES2015 where you can define a Polymer component as a regular javascript class, very similar to a React component. All these component frameworks in the end converge to similar patterns and architecture :)