This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injector} from 'angular2/core'; | |
let appInjectorRef: Injector; | |
export const appInjector = (injector?: Injector):Injector => { | |
if (injector) { | |
appInjectorRef = injector; | |
} | |
return appInjectorRef; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ViewChild, Inject, ContentChildren, QueryList, ContentChild, | |
ElementRef, Input, forwardRef, AfterViewInit, EventEmitter } from 'angular2/core'; | |
import { Subject } from 'rxjs'; | |
const imagesLoaded = require('imagesloaded'); | |
@Directive({ | |
selector: '[masonry-item]', | |
host: { | |
'[style.position]': 'position', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type definitions for Feathers | |
// Project: http://feathersjs.com/ | |
// Definitions by: Jack Guy <http://thatguyjackguy.com> | |
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
import { Application, Handler, ErrorRequestHandler } from 'express'; | |
type HandlerArgument = Handler | Handler[]; | |
export = Feathers; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
const iceCreamPrices = ['$5.50', '$5.75', '$6.00']; | |
let iceCreamFlavorToPrice; | |
for (let i = 0; i < iceCreamFlavors.length; i++) { | |
iceCreamFlavorToPrice[iceCreamFlavors[i]] = iceCreamPrices[i]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, zip } from 'rxjs'; | |
import { scan } from 'rxjs/operators'; | |
const iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
const iceCreamPrices = ['$5.50', '$5.75', '$6.00']; | |
const iceCreamFlavorToPrice$ = zip( | |
from(iceCreamFlavors), | |
from(iceCreamPrices), | |
).pipe(scan((prev, [flavor, price]) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIceCreamFlavorToPrice(flavors, prices) { | |
let iceCreamFlavorToPrice; | |
for (let i = 0; i < flavors.length; i++) { | |
iceCreamFlavorToPrice[flavors[i]] = prices[i]; | |
} | |
return iceCreamFlavorToPrice; | |
} | |
let iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
let iceCreamPrices = ['$5.50', '$5.75', '$6.00']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, fromEvent, zip } from 'rxjs'; | |
import { scan } from 'rxjs/operators'; | |
const initialIceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
const initialIceCreamPrices = ['$5.50', '$5.75', '$6.00']; | |
const iceCreamFormSubmit$ = fromEvent(formEl, 'submit'); | |
const iceCreamFormFlavors$ = iceCreamFormSubmit$.pipe((map(({flavor}) => flavor))); | |
const iceCreamFormPrices$ = iceCreamFormSubmit$.pipe((map(({price}) => price))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIceCreamById (iceCreamId) { | |
return fetch(`/icecream/${id}`); | |
} | |
const iceCreamIds = [4, 5, 10, 12]; | |
// Slow, effectively synchronous | |
for (let iceCreamId of iceCreamIds) { | |
console.log(await getIceCreamById(iceCreamId)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, fromPromise } from 'rxjs'; | |
const iceCreamIds = [4, 5, 10, 12]; | |
from(iceCreamIds).pipe( | |
flatMap((iceCreamId) => fromPromise(getIceCreamById(iceCreamId))) | |
).subscribe((iceCream) => { | |
console.log(iceCream); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from(iceCreamIds).pipe( | |
withLatestFrom( | |
iceCreamAuth$, | |
iceCreamPreferences$, | |
iceCreamVendors$, | |
iceCreamInventory$, | |
iceCreamTemperature$, | |
), | |
map(([ |
OlderNewer