Top Banner
Booting up with Polymer @marcushellberg / vaadin
45

Booting up with polymer

Apr 15, 2017

Download

Software

Marcus Hellberg
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Booting up with polymer

Booting up with Polymer

@marcushellberg / vaadin

Page 2: Booting up with polymer

Why Web Components?

Page 3: Booting up with polymer
Page 4: Booting up with polymer
Page 6: Booting up with polymer
Page 7: Booting up with polymer

4 standards

– Custom elements

– HTML Imports

– Templates

– Shadow DOM

Page 8: Booting up with polymer
Page 9: Booting up with polymer

Do browsers support this?

Page 10: Booting up with polymer

Source: webcomponents.org

Page 11: Booting up with polymer

webcomponents.js

now also available as lite!

Page 12: Booting up with polymer

What is Polymer then?

– Helper library for building Web Components

– Comes with a collection of ready made Web Components

Page 13: Booting up with polymer

Building apps with Polymer

Page 14: Booting up with polymer

do we need a framework?

Page 15: Booting up with polymer

... the DOM is the framework

– Component model (= HTML elements)

– Data flow (= attributes, properties and events)

– Declarative format (= HTML)

– Extensible through Web Components

Page 16: Booting up with polymer

Building apps out of components

– Composition

– Encapsulation

– Mediator pattern

Business logic

API API

APIcomponent

child 1 child 2

Page 17: Booting up with polymer
Page 18: Booting up with polymer

full stack app

Page 19: Booting up with polymer

backend

Page 20: Booting up with polymer

Spring Boot

Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible.

Page 21: Booting up with polymer

– Create stand-alone Spring applications

– Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)

– Provide opinionated 'starter' POMs to simplify your Maven configuration

– Automatically configure Spring whenever possible

– Production-ready features such as metrics, health checks and externalized configuration

– Absolutely no code generation and no requirement for XML configuration

projects.spring.io/spring-boot

Page 22: Booting up with polymer

start.spring.io

Page 23: Booting up with polymer

Token authentication

– JSON Web Token

– Compact

– Self-contained

– header.payload.signature

Page 24: Booting up with polymer

JWT authentication

Client Server

1. Login request (username/password)

2. token gets returned to browser Authenticate, create token

3. Request, token in header

4. Response Validate token

Page 25: Booting up with polymer
Page 26: Booting up with polymer

Polymer app

Page 27: Booting up with polymer

Some additional tools we'll use

npm – development time JS dependencies

bower – Polymer dependencies

gulp – JS based build tool used to run some optimization tasks

...integrated into Maven build process

Page 28: Booting up with polymer

server

<summary-panel>

<login-page>

<expenses-editor>

<expense-application>

<expenses-page>

<expenses-list>

Page 29: Booting up with polymer
Page 30: Booting up with polymer

performance?

Page 31: Booting up with polymer
Page 32: Booting up with polymer

Optimizing

vulcanize – combine all imports into one file

crisper – pull out all JS into separate file for CSP compliance

htmlmin & uglify – minimize assets

turn on server gzip

Page 33: Booting up with polymer

gulp.task('build', function() { return gulp .src(SRC_DIR + '/elements.html') .pipe($.vulcanize({ inlineScripts: true, inlineCss: true })) .pipe($.crisper()) .pipe($.if('*.js', $.uglify({ preserveComments: 'some' }))) .pipe($.if('*.html', $.htmlmin({ customAttrAssign: [/\$=/], removeComments: true, collapseWhitespace: true }))) .pipe(gulp.dest(DEST_DIR)); });

Page 34: Booting up with polymer

mvncleanpackage-Pproduction

Page 35: Booting up with polymer

..more!

Load imports asynchronously

Style "app skeleton"

Use native shadow DOM where available

Page 36: Booting up with polymer
Page 37: Booting up with polymer
Page 38: Booting up with polymer

80% smaller and faster start

Page 39: Booting up with polymer

production?

Page 40: Booting up with polymer

Getting started with

Page 43: Booting up with polymer

github.com/vaadin-marcus/polymer-spring-boot

Page 44: Booting up with polymer

?!

Page 45: Booting up with polymer

thanks!

[email protected] @marcushellberg