Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

oh hai! @rob_dodson +RobDodson uber nerd

Slide 3

Slide 3 text

end to end with Polymer

Slide 4

Slide 4 text

polymer-todo.firebaseapp.com

Slide 5

Slide 5 text

#wisdom Solutions to Problems

Slide 6

Slide 6 text

Problem #1

Slide 7

Slide 7 text

( The Blank Page )

Slide 8

Slide 8 text

Web Development is complicated

Slide 9

Slide 9 text

Homescreen icons Responsive design Optimizing images Offline caching Concat & App manifest Grunt? Gulp?

Slide 10

Slide 10 text

Polymer Starter Kit

Slide 11

Slide 11 text

Responsive app layout & routing Components for nearly any app, out of the box. Unit test support with Web Component Tester Complete build chain for bringing your app to production.

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

But RoB, I’m super lazy

Slide 15

Slide 15 text

npm install generator-polymer -g oh snap!

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Problem #1

Slide 18

Slide 18 text

Problem #2

Slide 19

Slide 19 text

the app Breaking up

Slide 20

Slide 20 text

build your app out of small components

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Slide 23

Slide 23 text

Slide 24

Slide 24 text

Slide 25

Slide 25 text

Slide 26

Slide 26 text

Slide 27

Slide 27 text

Slide 28

Slide 28 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } } } });

Slide 29

Slide 29 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } } } }); Todos are objects in an array

Slide 30

Slide 30 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } } } }); Todos are bindable

Slide 31

Slide 31 text

an element for data? that’s CRAZY TALK!

Slide 32

Slide 32 text

data provider

Slide 33

Slide 33 text

data provider + bindings = sweet!

Slide 34

Slide 34 text

index.html

Slide 35

Slide 35 text

index.html

Slide 36

Slide 36 text

index.html

Slide 37

Slide 37 text

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

todo-view.html Polymer({ is: 'todo-view', properties: { todos: Array } }); Bind data to reduce boilerplate

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

communicate Need to

Slide 45

Slide 45 text

todo-view.html Polymer({ is: 'todo-view', properties: { todos: Array }, clearTodos: function() { … }, deleteTodo: function() { … }, addTodo: function() { … } });

Slide 46

Slide 46 text

todo-view.html Polymer({ is: 'todo-view', properties: { todos: Array }, clearTodos: function() { … }, deleteTodo: function() { … }, addTodo: function() { … } }); Mediate events

Slide 47

Slide 47 text

todo-view.html addTodo: function(e) { this.push('todos', { label: e.detail.value, isComplete: false }); }

Slide 48

Slide 48 text

Kinda like a traffic cop

Slide 49

Slide 49 text

Slide 50

Slide 50 text

Slide 51

Slide 51 text

You could type this yourself

Slide 52

Slide 52 text

AWESOME Or you could be

Slide 53

Slide 53 text

yo polymer:element

Slide 54

Slide 54 text

yo polymer:element

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

todo-list.html Polymer({ is: 'todo-list', properties: { todos: Array } }); Iterate over data with dom-repeat

Slide 58

Slide 58 text

Slide 59

Slide 59 text

todo-item.html Polymer({ is: 'todo-item', properties: { todo: Object }, _onDelete: function() { this.fire(‘delete-todo’, {todo: this.todo}); } });

Slide 60

Slide 60 text

todo-item.html Polymer({ is: 'todo-item', properties: { todo: Object }, _onDelete: function() { this.fire(‘delete-todo’, {todo: this.todo}); } }); Bind data to reduce boilerplate

Slide 61

Slide 61 text

todo-item.html Polymer({ is: 'todo-item', properties: { todo: Object }, _onDelete: function() { this.fire(‘delete-todo’, {todo: this.todo}); } }); Mediate events

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Problem #2

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Problem #3

Slide 66

Slide 66 text

production Getting to

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 69

Slide 69 text

REALTIME DATABASE

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } }

Slide 75

Slide 75 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } } Just an array

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

There’s an element for that

Slide 79

Slide 79 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true, value: function() { return [ { label: 'My first todo!', isComplete: false }, … ]; } }

Slide 80

Slide 80 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 81

Slide 81 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 82

Slide 82 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 83

Slide 83 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 84

Slide 84 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 85

Slide 85 text

index.html

Slide 86

Slide 86 text

index.html

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 92

Slide 92 text

AUTHENTICATION

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

{ "rules": { "users": { "$uid": { ".write": "auth.uid === $uid", ".read": "auth.uid === $uid" } } } } Path to a unique ID

Slide 96

Slide 96 text

{ "rules": { "users": { "$uid": { ".write": "auth.uid === $uid", ".read": "auth.uid === $uid" } } } } The user’s unique ID

Slide 97

Slide 97 text

{ "rules": { "users": { "$uid": { ".write": "auth.uid === $uid", ".read": "auth.uid === $uid" } } } } Authenticated user’s ID must match the path

Slide 98

Slide 98 text

// Authenticate a user with Google Sign in ref.authWithOAuthPopup('google', function(error, authData) { // Get the user’s todo list this.userRef = this.ref.child(‘users/‘ + authData.uid); });

Slide 99

Slide 99 text

There’s an element for that too

Slide 100

Slide 100 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 101

Slide 101 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 102

Slide 102 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 103

Slide 103 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 104

Slide 104 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 105

Slide 105 text

todo-data.html … No user? Open the sign-in dialog

Slide 106

Slide 106 text

todo-data.html _userChanged: function(user) { if (user) { this.userLocation = [ this.location, 'users', this.user.uid ].join('/'); } } Find the user’s todos in Firebase

Slide 107

Slide 107 text

todo-data.html Polymer({ is: 'todo-data', properties: { todos: { notify: true } } });

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

REALTIME DATABASE AUTHENTICATION HOSTING

Slide 110

Slide 110 text

HOSTING

Slide 111

Slide 111 text

npm install -g firebase-tools

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

Problem #3

Slide 115

Slide 115 text

Polymer starter kit Get rolling with

Slide 116

Slide 116 text

Small elements Break your app into

Slide 117

Slide 117 text

get to production Use Firebase to

Slide 118

Slide 118 text

bit.ly/polycasts

Slide 119

Slide 119 text

thanks! @rob_dodson +RobDodson credits Images by Gregor Črešnar, Aenne Brielmann, Michal Beno, Golden Roof, Rohith M S, Till Teenck, Julien Deveaux, Garrett Knoll, Matt Brooks, Nick Kinling, Brad Ashburn, Juan Pablo Bravo, Nicolas Vicent, Aha-Soft, Nicky Knicky, Max Cougar Oswald & Nihir Shah