polymer-vs-react



polymer-vs-react

0 0


polymer-vs-react


On Github tpluscode / polymer-vs-react

Google meets Facebook

Web components and flux

github.com/tpluscode/polymer-vs-react

github.com/tpluscode/polymer-flux

Google meets Facebook

Polymer and reflux.js

Web Components

Custom Elements

<my-uber-select>
  <option>Choose me</option>
</my-uber-select>
<select is="my-uber-select">
  <option>Choose me</option>
</select>

Templates

<template>
  <div>
    <span>This is reusable code!</span>.
  </div>
</template>

HTML imports

<!-- load not only JS and CSS -->
<script src="some-library.js" />
<!-- but also HTML fragments -->
<link rel="import" href="my-uber-select.html" />

Shadow DOM

Hide component's internals from outside markup

Polymer

Polymer

  • One custom element to rule them all
  • Two-way data binding
  • Shadow DOM or Shady DOM
  • CSS extensions
  • Vulcanize tool
  • Web Components Tester
  • Many pre-built elements
  • Much more

Polymer 1.0 breaking changes

  • New syntax
  • One-way binding by default
  • Less fancy expressions
  • Behaviors
  • CSS extensions
  • Full polyfill not necessary
  • Local DOM API

0.5 -> 1.0 Migration guide

In the beginning there was MVC

And then there was Flux

Polymer + reflux*

* reflux/refluxjs@github

Why reflux?

Flux

  • Singleton dispatcher
  • Actions are strings
  • Stores use
    switch
  • Dispatcher.waitFor([])

reflux

  • No dispatcher
  • Actions are functions
  • Stores listen to actions
  • Chained stores or joined listeners

DEMO

source

Summary

  • Flux enables complex data flows and parallel logic
  • Everything is a custom element
    • Could use more events
  • Polymer takes some practise
    • non-WebKit browsers
    • completely different approach
    • great documentation

Useful links

Thank you

Google meets Facebook Web components and flux github.com/tpluscode/polymer-vs-react github.com/tpluscode/polymer-flux