Closed pub-technology closed 4 years ago
Behaviors are the Polymer 1 way of sharing logic so you should use them. https://polymer-library.polymer-project.org/1.0/docs/devguide/behaviors
Regarding JS files: while you could technically try using native ES modules with polyfilled HTML Imports, this use case hasn't been considered at times when Polymer 1 has been built.
BTW you can use tools like jscpd to find duplicates in code.
Thanks for your advanced @web-padawan
Today, 2020 I'm working in a legacy system with POLYMER 1 (v.1.9.3)
This project created 4 years ago. I try to review codebase however I can't find any way to share logic between components in this project.
All Styles + HTML + Logic in 1 FILE. (Code between components seem duplicate everywhere.) In official document: We can share logic by using "BEHAVIOR"
Does that make sense if we have too more Behavior in our projects.
Expectation :
When I create a component I try with the structure below
Another Solution: As the traditional website - We create PURE JS File and import to Polymer component to use and share between components.