A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
app.factory('BearerAuthInterceptor', function ($window, $q) { | |
return { | |
request: function(config) { | |
config.headers = config.headers || {}; | |
if ($window.localStorage.getItem('token')) { | |
// may also use sessionStorage | |
config.headers.Authorization = 'Bearer ' + $window.localStorage.getItem('token'); | |
} | |
return config || $q.when(config); | |
}, |
.platform-android4_1 { | |
/*Any styles for android 4.1*/ | |
} | |
.platform-android4_3 { | |
/*Any styles for android 4.3*/ | |
} | |
.platform-android4_4 { | |
/*Any styles for android 4.4*/ |
function arrayBufferToStringAsync( /*ArrayBuffer*/ buffer) { | |
var reader = new FileReader(); | |
return readAsync(reader, 'Text', new Blob([buffer])).then(function() { | |
return new Promise(function(resolve, reject) { | |
resolve(reader.result); | |
}); | |
}); | |
}; | |
function arrayBufferToHexAsync( /*ArrayBuffer*/ buffer) { |
It’s all about the key selector
What determines the impact of a selector is its key selector. The key selector is a very important thing in the world of CSS as browsers read selectors
right to left
. This means the key selector is the last one before the opening {, for example:
.header ul { /* ‘ul’ is the key selector */ }
.ul li a { /* ‘a’ is the key selector */ }
p:last-child { /* ‘:last-child’ is the key selector */ }
const {app, BrowserWindow} = require('electron') | |
const path = require('path') | |
const url = require('url') | |
// Keep a global reference of the window object, if you don't, the window will | |
// be closed automatically when the JavaScript object is garbage collected. | |
let win | |
function createWindow () { | |
// Create the browser window. |
This vanilla ES6 function async
allows code to yield
(i.e. await
) the asynchronous result of any Promise
within. The usage is almost identical to ES7's async/await
keywords.
async/await
control flow is promising because it allows the programmer to reason linearly about complex asynchronous code. It also has the benefit of unifying traditionally disparate synchronous and asynchronous error handling code into one try/catch block.
This is expository code for the purpose of learning ES6. It is not 100% robust. If you want to use this style of code in the real world you might want to explore a well-tested library like co, task.js or use async/await
with Babel. Also take a look at the official async/await
draft section on desugaring.
- node.js - 4.3.2+ (maybe earlier with
// in preload scripts, we have access to node.js and electron APIs | |
// the remote web app will not have access, so this is safe | |
const { ipcRenderer: ipc, remote } = require('electron'); | |
init(); | |
function init() { | |
// Expose a bridging API to by setting an global on `window`. | |
// We'll add methods to it here first, and when the remote web app loads, | |
// it'll add some additional methods as well. |
In a few simple steps we will create an app that has a link with a counter that increases every time we click it.
We will start with very low and rudementary implementation of a store and with each example evolve it to reach a basic Flux and then Redux implementation.
- Global variable - single component
- Global variable - multiple components
- Props
- State
- Flux
- Redux
<h1>Angular 2 Recursive List</h1> | |
<ul> | |
<ng-template #recursiveList let-list> | |
<li *ngFor="let item of list"> | |
{{item.title}} | |
<ul *ngIf="item.children.length > 0"> | |
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container> | |
</ul> | |
</li> | |
</ng-template> |