View data-loading-polymer.md

Declarative data loading in Polymer

  • Rather than writing a lot of imperative code how can we write more straightforward/simpler/consistent code, less prone to bugs.

Nextgen data loading components

  • Spawned off with needing to solve binding and data store issues when updgrading to Polymer 1.
    • Polymer 0.x used the Object observe to update bindings. We referenced a global store using basically an Object.assign function that updated elements referencing those objects.
    • Came up with an inf-store-observer component to listen for and bind updates
View calculator.js
<!DOCTYPE html>
<html>
<head>
<title>Data loading/binding demo</title>
<style>
body {
font-family: monospace, Helvetica, sans-serif;
padding: 20px;
margin: 0px;
background: #E6E7E8;
View benchmark-template.js
/**
* Simple benchmark copy paste for browsers using Benchmark.js
* See their documentation: https://benchmarkjs.com/
* Edit the different suite add() sections below to change your tests or add new ones.
*/
var Script = function(url) {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = url;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
View path-val.js
// via http://www.redotheweb.com/2015/09/18/declarative-imperative-js.html
function getValue(object, propertyName) {
if (!propertyName) throw new Error('Impossible to set null property');
return typeof object === 'undefined' ? undefined : object[propertyName];
}
function getNestedValue(object, propertyName) {
return propertyName.split('.').reduce(getValue, object);
}
View reduce.js
var input = [[2,6],[3,5],[7,21],[20,21]];
var expectedOutput = [[2,6],[7,21]];
var rangesOverlap = function(range1, range2) {
return (
(range1[1] >= range2[0] && range1[1] <=range2[1]) ||
(range1[0] <= range2[0] && range1[1] >= range2[0])
);
};
View es5-6.js
var params = { t: 123, type: 'mytype', channelId: 'mychan', badge:'thebadge' };
var allowedPersonParams = ["type", "channelId", "badge", "since", "until"];
// ES5
var result = {};
allowedPersonParams.forEach(function (paramName) {
if (currentParams[paramName]) {
result[paramName] = currentParams[paramName];
}
View gist:cbf92b33db85d31eff86
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>console test</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css">
<script src="lib/jasmine-2.2.0/jasmine.js"></script>
View gist:0e7d096151e0ca02a020
:%s/\/\*\{-1}\_.\{-}\*\///g
View gist:ac4594ce5d4d6e3357ba
/*
Gmail Client (ideas)
Usage:
var gmailClient = newGmailClient(myAccessToken);
var response = gmailClient.execute({
url: "users/me/messages",
headers: {},
View willen-zum-leben
Zwei Dinge hat das Denken zu leisten: uns aus der naiven zur vertiefen Welt-
und Lebensbejahung zu füren und uns von ethischen Regungen zu einer
denknotwendigen Ethic gelangen zu lassen.
Vertiefe Welt- und Lebensbejahung besteht darin, dass wir den Willen haben,
unser Leben und alles durch uns irgendwie beeinflussbare Sein zu erhalten und
auf seinen höchsten Wert zu bringen. Sie verlangt von uns, dass wir alle
Ideale der materiellen und geistigen Vervollkommnung des Menschen, der
Gesellschaft und der Menschheit denken und uns durch sie zu stetem Wirken und
stetem Hoffen bestimmen lassen. Sie erlaubt uns nicht, uns auf uns selber