By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
Table of Contents
/* | |
* Observable | |
*/ | |
var xs = Rx.Observable.range(0, 3) | |
xs.subscribe(log) | |
//=> 0 | |
//=> 1 | |
//=> 2 |
Function::define = (prop, desc) -> | |
Object.defineProperty this.prototype, prop, desc | |
class GetterSetterTest | |
constructor: (@_obj = {}) -> | |
# 'obj' is defined via the prototype, the definition proxied through | |
# to 'Object.defineProperty' via a function called 'define' providing | |
# some nice syntactic sugar. Remember, the value of '@' is | |
# GetterSetterTest itself when used in the body of it's class definition. |
// Original - @Gozola. This is a reimplemented version (with a few bug fixes). | |
window.WeakMap = window.WeakMap || (function () { | |
var privates = Name() | |
return { | |
get: function (key, fallback) { | |
var store = privates(key) | |
return store.hasOwnProperty("value") ? | |
store.value : fallback | |
}, |
// Credits: Adam's answer in http://stackoverflow.com/a/20786262/69362 | |
// Paste this in browser's console | |
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope'); | |
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){ | |
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams); | |
}); | |
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){ | |
console.log('$stateChangeError - fired when an error occurs during transition.'); |
// Primitive hash function that for a string returns a positive 32 bit int | |
// Do not use in production, use murmur3 or fnv1 | |
// You can improve this by changing 5 to 31 | |
Object.defineProperty(String.prototype, 'hashCode', { | |
value: function() { | |
var hash = 0, i, chr; | |
for (i = 0; i < this.length; i++) { | |
chr = this.charCodeAt(i); | |
hash = ((hash << 5) - hash) + chr; | |
hash |= 0; // Convert to 32bit integer |
By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
Table of Contents
// ==UserScript== | |
// @name GM_download emulation | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description emulate GM_download functionality | |
// @require https://github.com/eligrey/FileSaver.js/raw/master/FileSaver.js | |
// @match http://tampermonkey.net/empty.html | |
// @grant GM_xmlhttpRequest | |
// @copyright 2014, Jan Biniok | |
// ==/UserScript== |
const I = x => x | |
const K = x => y => x | |
const A = f => x => f (x) | |
const T = x => f => f (x) | |
const W = f => x => f (x) (x) | |
const C = f => y => x => f (x) (y) | |
const B = f => g => x => f (g (x)) | |
const S = f => g => x => f (x) (g (x)) | |
const S_ = f => g => x => f (g (x)) (x) | |
const S2 = f => g => h => x => f (g (x)) (h (x)) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.