Slide 1

Slide 1 text

Uncomplexify your app with Polymer Starter Kit +Rob Dodson @rob_dodson

Slide 2

Slide 2 text

JAM https://goo.gl/0HxSK2

Slide 3

Slide 3 text

https://goo.gl/5oqPUy

Slide 4

Slide 4 text

https://goo.gl/c06yLS

Slide 5

Slide 5 text

when presented with an abundance of choice, you can feel increasingly unsure of whether yours is the right one - Addy Osmani

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

LET’S WORK TOGETHER Image:

Slide 9

Slide 9 text

What is Polymer?

Slide 10

Slide 10 text

Polymer is not a framework.

Slide 11

Slide 11 text

Existing Frameworks Applications Web Platform Web Components built with Polymer (or not)

Slide 12

Slide 12 text

READY FOR PRODUCTION

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Polymer Starter Kit

Slide 19

Slide 19 text

Polymer Starter Kit

Slide 20

Slide 20 text

Image: App templates

Slide 21

Slide 21 text

Navigation Cards Layout

Slide 22

Slide 22 text

Navigation List Detail

Slide 23

Slide 23 text

List Card Over

Slide 24

Slide 24 text

Image: Responsive breakpoints

Slide 25

Slide 25 text

Material Design breakpoints

Slide 26

Slide 26 text

Web App install banner Mobile Web defaults Meta theme color

Slide 27

Slide 27 text

Icons

Slide 28

Slide 28 text

Offline-first (in your app)

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

// While there is only one cache in this example, the same logic will handle the case where // there are multiple versioned caches. var expectedCacheNames = Object.keys(CURRENT_CACHES).map(function(key) { return CURRENT_CACHES[key]; }); event.waitUntil( caches.keys().then(function(cacheNames) { return Promise.all( cacheNames.map(function(cacheName) { if (expectedCacheNames.indexOf(cacheName) == -1) { // If this cache name isn't present in the array of "expected" cache names, then delete it. console.log('Deleting out of date cache:', cacheName); return caches.delete(cacheName); } }) ); }) ); }); // This sample illustrates an aggressive approach to caching, in which every valid response is

Slide 31

Slide 31 text

There’s an element for that!

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Service Worker caching Take your app offline with ease

Slide 34

Slide 34 text

DOWNLOAD developers.google.com/web/tools/polymer-starter-kit

Slide 35

Slide 35 text

Let’s build an app!

Slide 36

Slide 36 text

Prepare for code

Slide 37

Slide 37 text

polymer-starter-kit/ app/ .editorconfig .jscsrc .jshintrc bower.json gulpfile.js package.json

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

todo-item todo-list

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Single source of truth

Slide 43

Slide 43 text

todos Unidirectional data

Slide 44

Slide 44 text

todos Unidirectional data

Slide 45

Slide 45 text

todos Unidirectional data

Slide 46

Slide 46 text

todos change events Unidirectional data

Slide 47

Slide 47 text

index.html …

Slide 48

Slide 48 text

index.html … Use bindings without creating a new element

Slide 49

Slide 49 text

index.html … var app = document.querySelector(‘#app’); app.js

Slide 50

Slide 50 text

index.html … var app = document.querySelector(‘#app’); app.todos = [ { todo: ‘Go for a jog’, isComplete: false }, { todo: ‘Get some lunch’, isComplete: true }. … ]; app.js Our single source of truth

Slide 51

Slide 51 text

Finish talk so we can play A minimal component

Slide 52

Slide 52 text

Slide 53

Slide 53 text

Polymer({ is: 'todo-item' });

Slide 54

Slide 54 text

Slide 55

Slide 55 text

todo-item.html Polymer({ is: 'todo-item' });

Slide 56

Slide 56 text

todo-item.html Polymer({ is: 'todo-item' }); Local DOM is the DOM an elements is in charge of creating and managing

Slide 57

Slide 57 text

Shadow DOM || “Shady DOM” == Local DOM

Slide 58

Slide 58 text

Shadow DOM || “Shady DOM” == Local DOM

Slide 59

Slide 59 text

Shadow DOM || “Shady DOM” == Local DOM

Slide 60

Slide 60 text

todo-item.html Polymer({ is: 'todo-item' });

Slide 61

Slide 61 text

todo-item.html Polymer({ is: 'todo-item' }); Import additional dependencies

Slide 62

Slide 62 text

todo-item.html Polymer({ is: 'todo-item' }); Add ‘em to your template

Slide 63

Slide 63 text

todo-item.html Polymer({ is: 'todo-item' });

Slide 64

Slide 64 text

todo-item.html Polymer({ is: 'todo-item' }); These values should be passed in

Slide 65

Slide 65 text

todo-item.html Polymer({ is: 'todo-item', properties: { todo: String, isComplete: { type: Boolean, default: false } } }); Properties!

Slide 66

Slide 66 text

todo-item.html [[todo]] Polymer({ is: 'todo-item', properties: { todo: String, isComplete: { type: Boolean, default: false } } }); Bindings are one-way*

Slide 67

Slide 67 text

todo-item.html [[todo]] Polymer({ is: 'todo-item', properties: { todo: String, isComplete: { type: Boolean, default: false } } }); Bindings are one-way* * two-way also supported

Slide 68

Slide 68 text

Slide 69

Slide 69 text

Go for a jog

Slide 70

Slide 70 text

Announce changes

Slide 71

Slide 71 text

todo-item.html [[todo]] Polymer({ is: 'todo-item', properties: {…} });

Slide 72

Slide 72 text

todo-item.html [[todo]] Polymer({ is: 'todo-item', properties: {…}, _notifyCheckedToggled: function() { this.fire(‘todo-item-checked-toggled’); } }); Wire-up handlers declaratively

Slide 73

Slide 73 text

Data flows in via one-way bindings

Slide 74

Slide 74 text

Data flows in via one-way bindings User interacts with the element

Slide 75

Slide 75 text

Data flows in via one-way bindings Changes flow out via events User interacts with the element

Slide 76

Slide 76 text

Data flows in via one-way bindings Changes flow out via events Application state is modified User interacts with the element

Slide 77

Slide 77 text

Data flows in via one-way bindings Changes flow out via events Application state is modified User interacts with the element

Slide 78

Slide 78 text

Finish talk so we can play Go to the grocery store Take the recycling out Book a flight for upcoming Contemplate world domina Steal all of Addy’s ideas A collection of components

Slide 79

Slide 79 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } });

Slide 80

Slide 80 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } }); Data flowing in one-way

Slide 81

Slide 81 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } }); Stamp out DOM, for each item

Slide 82

Slide 82 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } });

Slide 83

Slide 83 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } }); Pass data on to todo-items

Slide 84

Slide 84 text

Slide 85

Slide 85 text

Go for a jog Work on slide deck Upgrade Firebase account Buy some coffee Grab some lunch Close some GitHub bugs

Slide 86

Slide 86 text

index.html … var app = document.querySelector(‘#app’); app.todos = [ { todo: ‘Go for a jog’, isComplete: false }, { todo: ‘Get some lunch’, isComplete: true }. … ]; app.js Our single source of truth

Slide 87

Slide 87 text

index.html var app = document.querySelector(‘#app’); app.todos = [ { todo: ‘Go for a jog’, isComplete: false }, { todo: ‘Get some lunch’, isComplete: true }. … ]; app.js Our single source of truth

Slide 88

Slide 88 text

todos change events Unidirectional data

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

Thinking by Edward Boatman from the Noun Project Sign in? Storing data? Deploying?

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 93

Slide 93 text

REALTIME DATABASE

Slide 94

Slide 94 text

// Write some data ref.set({ name: ‘Rob Dodson’ }); // Push Array-like data ref.push({ isComplete: false, todo: ‘A new todo!’ }); app.js // Create a connection to Firebase var ref = new Firebase(‘https://.firebaseio.com');

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

app.js // Listen for changes from Firebase ref.on('value', function(snapshot) { console.log(snapshot.val()); });

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

index.html var app = document.querySelector(‘#app’); app.todos = [ { todo: ‘Go for a jog’, isComplete: false }, { todo: ‘Get some lunch’, isComplete: true }. … ]; app.js Our single source of truth

Slide 99

Slide 99 text

Single source of truth

Slide 100

Slide 100 text

Single source of truth

Slide 101

Slide 101 text

app.js this.ref.on('value', this.renderTodos.bind(this));

Slide 102

Slide 102 text

app.js this.ref.on('value', this.renderTodos.bind(this)); app.renderTodos = function(snapshot) { this.todos = []; }; Throw away old state

Slide 103

Slide 103 text

app.js this.ref.on('value', this.renderTodos.bind(this)); app.renderTodos = function(snapshot) { this.todos = []; snapshot.forEach(function(childSnapshot) { var item = childSnapshot.val(); this.push('todos', item); }.bind(this)); };

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 108

Slide 108 text

AUTHENTICATION

Slide 109

Slide 109 text

{ "rules": { "users": { "$uid": { ".write": "auth.uid === $uid", ".read": "auth.uid === $uid" } } } }

Slide 110

Slide 110 text

app.js // Authenticate a user with Google Sign in ref.authWithOAuthPopup('google', function(error, authData) { console.log(authData); });

Slide 111

Slide 111 text

app.js // Check to see if the user is already signed in var authData = this.ref.getAuth();

Slide 112

Slide 112 text

app.js // Check to see if the user is already signed in var authData = this.ref.getAuth(); if (authData) { // Get the user’s todo list this.userRef = this.ref.child(‘users/‘ + authData.uid); } else { // Show sign in screen this.$.signInDialog.open(); }

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 115

Slide 115 text

HOSTING

Slide 116

Slide 116 text

npm install -g firebase-tools

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

Polymer is lean, and production ready

Slide 121

Slide 121 text

Starter Kit gets you up and running

Slide 122

Slide 122 text

Firebase gets you into production

Slide 123

Slide 123 text

bit.ly/polycasts

Slide 124

Slide 124 text

Polymer Summit September 14-15, 2015 polymer-project.org/summit

Slide 125

Slide 125 text

polymer-project.org

Slide 126

Slide 126 text

+Rob Dodson @rob_dodson Thank You!

Slide 127

Slide 127 text

code_slides.txt For format coloring, visit j.mp/iohighlighter in Safari
 and copy + paste into Keynote If your code snippet is over 6 lines, use a full- page slide of code in this style code_slides.txt protected void onTryUpdate(int reason) throws RetryException { // Do some awesome stuff int foo = 15; publishArtwork(new Artwork.Builder() .title(photo.name) .imageUri(Uri.parse(photo.image_url)) .viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://500px.com/photo/" + photo.id))) .build()); scheduleUpdate(System.currentTimeMillis() + ROTATE_TIME_MILLIS); }