Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What if there isn’t?

8314890e50d87c60b2ab5fdab90a9630?s=47 Surma
September 27, 2015

What if there isn’t?

8314890e50d87c60b2ab5fdab90a9630?s=128

Surma

September 27, 2015
Tweet

Transcript

  1. 1

  2. 01 What if there isn’t?! Surma @surmair +PolymerProject @Polymer 2

  3. 3

  4. 4 +PolymerProject @Polymer <google-map> <google-youtube> <firebase-collection> <?>

  5. 5

  6. +PolymerProject @Polymer 6 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  7. +PolymerProject @Polymer 7 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  8. +PolymerProject @Polymer 8 <dom-module id="reddit-api"> <template> <iron-jsonp-library notify-event="data" on-data="_newData" library-url="[[_requestUrl]]"

    ></iron-jsonp-library> </template> <!-- … --> </dom-module>
  9. +PolymerProject @Polymer 9 <script> Polymer({ is: 'reddit-api', properties: { subreddit:

    { type: String, reflectToAttribute: true, notify: true }, // ... }); </script>
  10. +PolymerProject @Polymer 10 <script> Polymer({ is: 'reddit-api', properties: { sorting:

    { type: String, reflectToAttribute: true, notify: true }, // ... }); </script>
  11. +PolymerProject @Polymer 11 <script> Polymer({ is: 'reddit-api', properties: { posts:

    { type: Array, readOnly: true, value: function() { return []; }, notify: true }, // ... }); </script>
  12. +PolymerProject @Polymer 12 <script> Polymer({ is: 'reddit-api', properties: { baseUrl:

    { type: String, value: 'https://api.reddit.com', notify: true }, // ... }); </script>
  13. +PolymerProject @Polymer 13 <script> Polymer({ is: 'reddit-api', properties: { _requestUrl:

    { type: String, computed: '_computeUrl(baseUrl, subreddit, sorting)', notify: true }, // ... }); </script>
  14. +PolymerProject @Polymer 14 <script> Polymer({ is: 'reddit-api', _computeUrl: function(baseUrl, subreddit,

    sorting) { return baseUrl + subreddit + '/' + sorting + '?jsonp=%%callback%%'; }, </script>
  15. +PolymerProject @Polymer 15 <dom-module id="reddit-api"> <template> <iron-jsonp-library notify-event="data" on-data="_newData" library-url="[[_requestUrl]]"

    ></iron-jsonp-library> </template> <!-- … --> </dom-module>
  16. +PolymerProject @Polymer 16 <script> 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 }; })); } }); </script>
  17. +PolymerProject @Polymer 17 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  18. +PolymerProject @Polymer 18 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  19. +PolymerProject @Polymer 19 <paper-radio-group selected="{{sorting}}"> <paper-radio-button name="hot"> </paper- radio-button> <paper-radio-button

    name="new">✨ </paper- radio-button> <paper-radio-button name="controversial"> </ paper-radio-button> </paper-radio-group>
  20. +PolymerProject @Polymer 20 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  21. +PolymerProject @Polymer 21 <template is="dom-bind"> <reddit-api posts="{{posts}}" sorting="{{sorting}}" subreddit="{{subreddit}}"></reddit-api> <paper-input

    value="{{subreddit::change}}"></ paper-input> <paper-radio-group selected="{{sorting}}"> <!-- ... --> </paper-radio-group> <template is="dom-repeat" items="[[posts]]"> <a class=“post” href="[[item.link]]">[[item.title]]</a> </template> </template>
  22. 22

  23. 23

  24. +PolymerProject @Polymer 24 <platinum-sw-register skip-waiting clients-claim auto-register state="{{state}}" on-service-worker-error="swError" on-service-worker-updated="swUpdated"

    on-service-worker-installed="swInstalled"> <!-- … one or more <platinum-sw-*> … --> </platinum-sw-register>
  25. +PolymerProject @Polymer 25 <platinum-sw-import-script href="custom-fetch-handler.js"> </platinum-sw-import-script> <platinum-sw-fetch handler="customFetchHandler" path="/(.*)/customFetch"> </platinum-sw-fetch>

  26. +PolymerProject @Polymer 26 _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); } } }
  27. +PolymerProject @Polymer 27 return Promise.all(paramsPromises). then(function(paramsResolutions) { var params =

    {} paramsResolutions. forEach(function(childParams) { Object.keys(childParams). forEach(/* merge into params */); }); })
  28. +PolymerProject @Polymer 28 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 }).then(...);
  29. 01 Surma @surmair +PolymerProject @Polymer 29 https://elements.polymer-project.org/ https://github.com/PolymerElements /platinum-sw /platinum-push-messaging

    https://github.com/GoogleWebComponents /firebase-element /google-map /...