Is Google's Polymer a fully functioning Frontend Framework to Subsitute OR Complement other Frontend Frameworks?

前端 未结 6 1426
你的背包
你的背包 2020-12-09 15:11

The question is in regard to AngularJS, BackboneJS, EmberJS and the other frameworks.

I have to translate a project from php to javascript and I have to decide, if I

相关标签:
6条回答
  • 2020-12-09 15:26

    I put together some router demos. The "missing parts" really depend on what type of application you're building.

    https://github.com/erikringsmuth/polymer-router-demos

    0 讨论(0)
  • 2020-12-09 15:32

    I've used it as both, as an enhancement to an app written in another framework, and as the full framework itself, where it was responsible for every element on the page.

    I really like just about everything about Polymer, so I've been very happy using it for the whole app, even built my own router. If you've got an existing app I'd recommend dipping your toe in the water, as Polymer works great composed into other apps to see if it's to your liking.

    0 讨论(0)
  • 2020-12-09 15:34

    Polymer is almost fully functional. Currently it is missing routing for example but this doesn't mean you can't do this with Polymer.

    There is now https://elements.polymer-project.org/elements/app-route

    In Dart also dependency injection works fine with Polymer because of the types. If it's possible in Dart, it's possible in JS as well because Dart transpiles to JS. DI in plain JS might be more cumbersome though.

    In this package (Dart) https://github.com/bwu-dart/bwu_polymer_routing I made the routing and DI packages used by Angular.dart available for Polymer. There are also routing packages for Polymer.js available.

    0 讨论(0)
  • 2020-12-09 15:39

    Let me give this another try:

    The key behind web-components (and thus Polymer) is, that they are self-contained. You have a web-component somewhere, you import it, and (if you're lucky) it just works, wherever it comes from. The web-component will NOT interfere other components. So doing things like MVC is not Polymers business (although it provides a data-binding mechanism), as this belongs to the process of tying things together. It is considered to be best practice that these kind of things are solved by creating new elements too, that create and react to events. When it comes to the model you code non-visual web-components, that don't have/need a template. TodoMVC has an (outdated) example for that (https://github.com/tastejs/todomvc/tree/gh-pages/examples/polymer).

    So Angular gives you a path to follow on how to do MVVM, whereas it is up to you on how to do the "logic" in your app when using Polymer. IMHO Angular is for more complex and rather enclosed apps, whereas Polymer is for any kind of app, that embraces the web. You even can use Polymer, if you're not writing an app at all ;)

    0 讨论(0)
  • 2020-12-09 15:41

    From the Polymer Starter Kit: "Framework-free, or framework-compatible Build your app out of elements, or wire in an external framework to handle business logic. It's up to you!"

    Update: What was described as Carbon Elements seems to fall under:

    Polymer(version 2) App Toolbox

    • Component-based architecture using Polymer and web components.
    • Responsive design using the app layout components.
    • Modular routing using the elements.
    • Localization with <app-localize-behavior>.
    • Turnkey support for local storage with app storage elements.
    • Offline caching as a progressive enhancement, using service workers.
    • Build tooling to support serving your app multiple ways: unbundled for delivery over HTTP/2 with server push, and bundled for delivery over HTTP/1.

    Carbon Elements adding framework features

    During The Polymer Summit 2015 Keynote, Google announced a new "Polymer idiomatic and framework oriented" set of elements, tentatively named the Carbon elements.

    Some quotes from the longer tjsavage answer regarding Angular 2 vs Polymer Carbon: "The trick is in thinking about the web platform as an application framework... Polymer the library is to the web components component model as the carbon elements will be to using the web platform itself as an application framework: the opinionated rails to make it easier to understand and achieve."

    "Angular 2 will provide one way of structuring your application that uses Angular's view of what makes a good application structure. The carbon elements will provide a different way of structuring your application that more directly uses what the web platform itself provides as its structural underpinning."

    0 讨论(0)
  • 2020-12-09 15:47

    IMHO both are two different things and they both are to serve two different purposes. Though they have some common features to offer, data-binding can be one of them.

    Polymer

    If you truly want to use the Awesome Webcomponents, Polymer is one way to achieve that. There are other options like you can go with your vanilla JS, or use other libraries like X-Tag from Mozilla or Bosonic. These libraries polyfill the webcomponent features which are still in drafted state. So, these libs help us have/provide the same user experience across browsers even where there is no native support for the webcomponents.

    Angular

    This is a full fledged MVC framework. And people here know what Angular as an MVC framework includes/provides.

    That all said to answer your question

    Google's Polymer is not exactly a fully functioning Frontend Framework and can be used as a Subsitute OR Complement to other Frontend Frameworks. It can be used as a substitution for the V part in Angular as MVC. Like people use React as V in different frameworks. It is not much a different case for me. Being more specific in case of Angular, Polymer is like directives in Angular 1.x while like components in upcoming Angular 2.x.


    References

    To be more sure of what I am talking about and for additional sources on how to use the Polymer with Angular2 (Angular2 not released to this date)

    • you can check this video at "https://youtu.be/7WgEuNZCCHk?t=32m15s" starting from time 32:15 where Rob explains how to use the generic webcomponents/polymer as the components/View in the Angular2.
    • you can check this project "https://github.com/rkirov/youtube-app" which uses Angular2 and google-youtube web component.
    • https://github.com/ebidel/polymer-experiments/tree/master/polymer-and-angular/together
    • From the polymer-starter-kit

      Framework-free, or framework-compatible Build your app out of elements, or wire in an external framework to handle business logic. It's up to you!

    So, in my view these two projects are not competing each other.


    Webcomponent Specs

    The webcomponent specs are here for one's reference

    • Custom Elements - http://w3c.github.io/webcomponents/spec/custom/
    • HTML Imports - http://w3c.github.io/webcomponents/spec/imports/
    • Shadow DOM - http://w3c.github.io/webcomponents/spec/shadow/

    I just wish the webcomponents are native to the evergreen browsers ASAP.

    0 讨论(0)
提交回复
热议问题