Slide 1

Slide 1 text

What if there isn’t?! Surma @surmair

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

>

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Slide 6

Slide 6 text

Slide 7

Slide 7 text

Slide 8

Slide 8 text

Polymer({ is: 'reddit-api', properties: { subreddit: { type: String, reflectToAttribute: true, notify: true }, // ... });

Slide 9

Slide 9 text

Polymer({ is: 'reddit-api', properties: { sorting: { type: String, reflectToAttribute: true, notify: true }, // ... });

Slide 10

Slide 10 text

Polymer({ is: 'reddit-api', properties: { posts: { type: Array, readOnly: true, value: function() { return []; }, notify: true }, // ...

Slide 11

Slide 11 text

Polymer({ is: 'reddit-api', properties: { baseUrl: { type: String, value: 'https://api.reddit.com', notify: true }, // ... });

Slide 12

Slide 12 text

Polymer({ is: 'reddit-api', properties: { _requestUrl: { type: String, computed: '_computeUrl(baseUrl, subreddit, sorting)', notify: true }, // ... });

Slide 13

Slide 13 text

Polymer({ is: 'reddit-api', _computeUrl: function(baseUrl, subreddit, sorting) { return baseUrl + subreddit + '/' + sorting + '?jsonp=%%callback%%'; },

Slide 14

Slide 14 text

Slide 15

Slide 15 text

Polymer({ is: 'reddit-api', _newData: function(ev) { this._setPosts( ev.detail[0].data.children. map(function(post) { return { title: post.data.title, link: post.data.url }; })); }

Slide 16

Slide 16 text

Slide 17

Slide 17 text

Slide 18

Slide 18 text

Slide 19

Slide 19 text

Slide 20

Slide 20 text

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Slide 24

Slide 24 text

Slide 25

Slide 25 text

_constructServiceWorkerUrl: function() { var paramsPromises = []; var cs = Polymer.dom(this).children; for (var i = 0; i < cs; i++) { if (typeof cs[i]._getParameters === 'function') { var params = cs[i]._getParameters(); paramsPromises.push(params); } } }

Slide 26

Slide 26 text

return Promise.all(paramsPromises). then(function(paramsResolutions) { var params = {} paramsResolutions. forEach(function(childParams) { Object.keys(childParams). forEach(/* merge into params */); }); })

Slide 27

Slide 27 text

var serviceWorkerUrl = new URL(this.href, window.location); serviceWorkerUrl.search = Object.keys(params).sort() .map(function(key) { return encodeURIComponent(key) + "=" + encodeURIComponent(params[key]); }).join('&'); navigator.serviceWorker .register(serviceWorkerUrl, { scope: this.scope

Slide 28

Slide 28 text

https://elements.polymer-project.org/ https://github.com/PolymerElements/platinum-sw /platinum-push-messaging https://github.com/GoogleWebComponents/firebase-element /google-map /… https://github.com/surma/polymer-reddit-api Surma @surmair