├── .gitignore ├── .eslintrc ├── test └── app │ └── dummy.test.js ├── client ├── css │ └── stocks.css ├── bootstrap.ts ├── services │ └── stocks.ts ├── components │ ├── dashboard.ts │ ├── summary.ts │ ├── app.ts │ └── manage.ts └── index.html ├── typings ├── angular2 │ ├── forms.d.ts │ ├── router.d.ts │ └── http.d.ts ├── tsd.d.ts ├── es6-promise │ └── es6-promise.d.ts └── rx │ ├── rx.d.ts │ └── rx-lite.d.ts ├── tsd.json ├── README.md ├── tsconfig.json ├── package.json ├── server └── bootstrap.js ├── karma.conf.js └── gulpfile.js /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | }, 5 | "rules": { 6 | "quotes": [2, "single", "avoid-escape"], 7 | "new-cap": 0 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/app/dummy.test.js: -------------------------------------------------------------------------------- 1 | 2 | describe('App', () => { 3 | 4 | it('Dummy test', (done) => { 5 | expect(true).to.be.true; 6 | return done(); 7 | }); 8 | 9 | }); -------------------------------------------------------------------------------- /client/css/stocks.css: -------------------------------------------------------------------------------- 1 | .stock-card.mdl-card { 2 | background: #333; 3 | } 4 | .stock-card.mdl-card.increase { 5 | background: #558B2F; 6 | color: #fff; 7 | } 8 | .stock-card.mdl-card.decrease { 9 | background: #C62828; 10 | color: #fff; 11 | } -------------------------------------------------------------------------------- /typings/angular2/forms.d.ts: -------------------------------------------------------------------------------- 1 | declare module "angular2/forms" { 2 | export var FORM_DIRECTIVES: any; 3 | export var FORM_BINDINGS: any; 4 | export var Control: any; 5 | export class ControlGroup { 6 | constructor (data: any); 7 | value: any; 8 | controls: any; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /client/bootstrap.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {bootstrap} from 'angular2/angular2'; 4 | import {ROUTER_BINDINGS} from 'angular2/router'; 5 | import {HTTP_BINDINGS} from 'angular2/http'; 6 | 7 | import {App} from './components/app'; 8 | 9 | bootstrap(App, [ROUTER_BINDINGS, HTTP_BINDINGS]); 10 | -------------------------------------------------------------------------------- /typings/tsd.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | /// 8 | -------------------------------------------------------------------------------- /tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings", 6 | "bundle": "typings/tsd.d.ts", 7 | "installed": { 8 | "angular2/angular2.d.ts": { 9 | "commit": "6baa15a0d760170b4aeefab68d581a1ea4034aa6" 10 | }, 11 | "es6-promise/es6-promise.d.ts": { 12 | "commit": "6baa15a0d760170b4aeefab68d581a1ea4034aa6" 13 | }, 14 | "rx/rx.d.ts": { 15 | "commit": "6baa15a0d760170b4aeefab68d581a1ea4034aa6" 16 | }, 17 | "rx/rx-lite.d.ts": { 18 | "commit": "6baa15a0d760170b4aeefab68d581a1ea4034aa6" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Stock tracking app written with Angular2. 2 | 3 | ### Setup 4 | 5 | Just run `npm install && gulp go` to get everything setup and started. Then open up http://localhost:8080 and go! 6 | 7 | ### Thanks to these folks 8 | 9 | I've learned and borrowed from the following projects. 10 | 11 | - [angular2-minimalist-starter](https://github.com/rogerpadilla/angular2-minimalist-starter) 12 | - [ng2-play](https://github.com/pkozlowski-opensource/ng2-play) 13 | - [ng2-play rj](https://github.com/rolandjitsu/ng2-play) 14 | - [angular2-webpack-starter](https://github.com/angular-class/angular2-webpack-starter) 15 | - [angular2-authentication-sample](https://github.com/auth0/angular2-authentication-sample) 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.0", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "declaration": false, 7 | "noImplicitAny": false, 8 | "removeComments": true, 9 | "noLib": false, 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "sourceMap": true, 13 | "outDir": "dist" 14 | }, 15 | "filesGlob": [ 16 | "typings/tsd.d.ts", 17 | "client/**/*.ts" 18 | ], 19 | "files": [ 20 | "typings/tsd.d.ts", 21 | "client/bootstrap.ts", 22 | "client/components/app.ts", 23 | "client/components/dashboard.ts", 24 | "client/components/manage.ts", 25 | "client/components/summary.ts", 26 | "client/services/stocks.ts" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /client/services/stocks.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { Inject } from 'angular2/angular2'; 3 | import { Http } from 'angular2/http'; 4 | 5 | let stocks: Array = ['AAPL', 'GOOG', 'FB', 'AMZN', 'TWTR']; 6 | 7 | export interface StockInterface { 8 | symbol: string, 9 | lastTradePriceOnly: number, 10 | change: number, 11 | changeInPercent: number 12 | } 13 | 14 | export class StocksService { 15 | http: Http; 16 | constructor(@Inject(Http) Http) { 17 | this.http = Http; 18 | } 19 | 20 | get() { 21 | return stocks; 22 | } 23 | 24 | add(stock) { 25 | stocks.push(stock); 26 | return this.get(); 27 | } 28 | 29 | remove(stock) { 30 | stocks.splice(stocks.indexOf(stock), 1); 31 | return this.get(); 32 | } 33 | 34 | load(symbols) { 35 | if (symbols) { 36 | return this.http.get('/api/snapshot?symbols=' + symbols.join()) 37 | .toRx() 38 | .map(res => res.json()) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /client/components/dashboard.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {Component, View, Directive, NgIf, NgFor} from 'angular2/angular2'; 4 | 5 | import {Summary} from './summary'; 6 | import {StocksService, StockInterface} from '../services/stocks'; 7 | 8 | @Component({ 9 | selector: 'dashboard', 10 | viewBindings: [StocksService] 11 | }) 12 | @View({ 13 | directives: [NgIf, NgFor, Summary], 14 | template: ` 15 |
16 |
17 | Loading 18 |
19 |
20 | 21 |
22 |
23 | ` 24 | }) 25 | export class Dashboard { 26 | stocks: Array; 27 | symbols: Array; 28 | 29 | constructor(service: StocksService) { 30 | this.symbols = service.get(); 31 | 32 | service.load(this.symbols) 33 | .subscribe(stocks => this.stocks = stocks); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /client/components/summary.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {Component, View, NgIf, NgClass} from 'angular2/angular2'; 4 | 5 | import {StockInterface} from '../services/stocks'; 6 | 7 | @Component({ 8 | selector: 'summary', 9 | properties: ['stock: symbol'] 10 | }) 11 | @View({ 12 | directives: [NgIf, NgClass], 13 | template: ` 14 |
15 | 16 |
17 |

18 | {{stock.symbol.toUpperCase()}}
19 | {{stock.lastTradePriceOnly | currency:'USD':true:'.2'}}
20 | {{stock.change | currency:'USD':true:'.2'}} ({{stock.changeInPercent | percent}}) 21 |

22 |
23 |
24 |
25 | ` 26 | }) 27 | export class Summary { 28 | stock: StockInterface; 29 | 30 | isNegative() { 31 | if (!this.stock || this.stock.change >= 0) { 32 | return false; 33 | } 34 | 35 | return true; 36 | } 37 | 38 | isPositive() { 39 | if (!this.stock || this.stock.change <= 0) { 40 | return false; 41 | } 42 | 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /client/components/app.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {Component, View} from 'angular2/angular2'; 4 | import {RouteConfig, Router, RouterOutlet, RouterLink} from 'angular2/router'; 5 | 6 | import {Dashboard} from './dashboard'; 7 | import {Manage} from './manage'; 8 | 9 | @RouteConfig([ 10 | {path: '/', as: 'dashboard', component: Dashboard}, 11 | {path: '/manage', as: 'manage', component: Manage} 12 | ]) 13 | 14 | @Component({ 15 | selector: 'app' 16 | }) 17 | @View({ 18 | directives: [RouterOutlet, RouterLink], 19 | template: ` 20 |
21 |
22 |
23 | Stock Tracker 24 |
25 | 29 |
30 |
31 |
32 | 33 |
34 |
35 | ` 36 | }) 37 | export class App { 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "0.1.0", 4 | "description": "Stock tracker in Angular 2", 5 | "main": "server/bootstrap.js", 6 | "scripts": { 7 | "start": "npm install && node ./node_modules/gulp/bin/gulp.js go" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/angular-in-action/hello-world.git" 12 | }, 13 | "keywords": [ 14 | "angular2" 15 | ], 16 | "author": "Jeremy Wilken ", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/angular-in-action/hello-world/issues" 20 | }, 21 | "homepage": "https://github.com/angular-in-action/hello-world#readme", 22 | "dependencies": { 23 | "angular2": "2.0.0-alpha.37", 24 | "express": "4.13.1", 25 | "reflect-metadata": "0.1.0", 26 | "systemjs": "0.18.4", 27 | "yahoo-finance": "0.2.11", 28 | "zone.js": "0.5.2" 29 | }, 30 | "devDependencies": { 31 | "del": "1.2.0", 32 | "eslint": "0.24.1", 33 | "gulp": "3.9.0", 34 | "gulp-changed": "1.2.1", 35 | "gulp-concat": "^2.6.0", 36 | "gulp-sourcemaps": "1.5.2", 37 | "gulp-tslint": "3.1.0-beta", 38 | "gulp-typescript": "2.7.8", 39 | "gulp-util": "3.0.6", 40 | "karma": "^0.13.9", 41 | "karma-chai": "^0.1.0", 42 | "karma-chrome-launcher": "~0.1.0", 43 | "karma-mocha": "^0.2.0", 44 | "karma-typescript-preprocessor": "0.0.19", 45 | "minimist": "1.1.3", 46 | "mocha": "^2.3.2", 47 | "run-sequence": "1.1.1", 48 | "tsd": "0.6.3", 49 | "typescript": "1.5.3" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Stock Tracker 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /client/components/manage.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {Component, View, NgFor} from 'angular2/angular2'; 4 | import {FORM_BINDINGS, FORM_DIRECTIVES, FormBuilder} from 'angular2/angular2'; 5 | 6 | import {StocksService} from '../services/stocks'; 7 | 8 | @Component({ 9 | selector: 'manage', 10 | viewBindings: [FORM_BINDINGS, StocksService] 11 | }) 12 | @View({ 13 | directives: [NgFor, FORM_DIRECTIVES], 14 | template: ` 15 |
16 |
17 |
18 |
19 | 20 |
21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 |
{{symbol}} 26 | 27 |
31 |
32 |
33 |
34 | ` 35 | }) 36 | export class Manage { 37 | symbols: Array; 38 | service: StocksService; 39 | stockForm: any; 40 | 41 | constructor(service: StocksService) { 42 | this.service = service; 43 | this.symbols = service.get(); 44 | 45 | let builder = new FormBuilder(); 46 | this.stockForm = builder.group({ 47 | stock: [''] 48 | }) 49 | } 50 | 51 | add() { 52 | this.symbols.push(this.stockForm.value.stock.toUpperCase()); 53 | } 54 | 55 | remove(symbol) { 56 | this.symbols = this.service.remove(symbol); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /server/bootstrap.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var express = require('express'); 4 | var path = require('path'); 5 | var yahooFinance = require('yahoo-finance'); 6 | var minimist = require('minimist'); 7 | 8 | // Express App 9 | var app = express(); 10 | var args = minimist(process.argv.slice(2), {default: {port: '8080'}}); 11 | 12 | var PORT = args.port; 13 | var DIST_DIR = path.join(__dirname, '..', 'dist'); 14 | 15 | // Send static files from these directories 16 | app.use('/lib', express.static(DIST_DIR + '/lib')); 17 | app.use('/client', express.static(DIST_DIR + '/client')); 18 | 19 | var router = express.Router(); 20 | 21 | // Endpoint to load snapshot data from yahoo finance 22 | router.get('/api/snapshot', function(req, res) { 23 | if (req.query.symbols) { 24 | var symbols = req.query.symbols.split(','); 25 | symbols.map(function(symbol) { 26 | return symbol.toUpperCase(); 27 | }); 28 | 29 | yahooFinance.snapshot({ 30 | symbols: symbols 31 | }, function(err, snapshot) { 32 | if (err) { 33 | res.status(401).send(err); 34 | } 35 | 36 | setTimeout(function() { 37 | res.status(200).send(snapshot); 38 | }, 5000); 39 | }); 40 | } else { 41 | res.status(400).send({message: 'The request requires at least one symbol. Try adding "?symbols=appl" to the request.'}); 42 | } 43 | }); 44 | 45 | // Endpoint to load historical data from yahoo finance. 46 | router.get('/api/historical/:symbol', function(req, res) { 47 | var today = new Date(); 48 | var yearAgo = new Date(today.getTime() - 1000 * 60 * 60 * 24 * 365); 49 | yahooFinance.historical({ 50 | symbol: req.params.symbol, 51 | from: yearAgo.toString(), 52 | to: today.toString() 53 | }, function(err, quotes) { 54 | if (err) { 55 | res.status(500).send(err); 56 | } 57 | 58 | res.status(200).send(quotes); 59 | }); 60 | }); 61 | 62 | // Send any other urls to the client app to load. 63 | router.get('*', function(req, res) { 64 | res.sendFile(DIST_DIR + '/client/index.html'); 65 | }); 66 | 67 | app.use('/', router); 68 | 69 | app.listen(PORT, function() { 70 | console.log('Server started at http://localhost:' + PORT); 71 | }); 72 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Tue Sep 15 2015 20:08:58 GMT-0500 (CDT) 3 | 4 | module.exports = function(config) { 5 | config.set({ 6 | 7 | // base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '', 9 | 10 | 11 | // frameworks to use 12 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 13 | frameworks: ['mocha', 'chai'], 14 | 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'test/app/**/*.js' 19 | ], 20 | 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | 26 | // preprocess matching files before serving them to the browser 27 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 28 | preprocessors: { 29 | '**/*.ts': ['typescript'] 30 | }, 31 | 32 | typescriptPreprocessor: { 33 | // options passed to the typescript compiler 34 | options: { 35 | sourceMap: false, // (optional) Generates corresponding .map file. 36 | target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5' 37 | module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd' 38 | noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type. 39 | noResolve: true, // (optional) Skip resolution and preprocessing. 40 | removeComments: true // (optional) Do not emit comments to output. 41 | }, 42 | // extra typing definitions to pass to the compiler (globs allowed) 43 | typings: [ 44 | 'typings/**/*.ts' 45 | ], 46 | // transforming the filenames 47 | transformPath: function(path) { 48 | return path.replace(/\.ts$/, '.js'); 49 | } 50 | }, 51 | 52 | 53 | // test results reporter to use 54 | // possible values: 'dots', 'progress' 55 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 56 | reporters: ['progress'], 57 | 58 | 59 | // web server port 60 | port: 9876, 61 | 62 | 63 | // enable / disable colors in the output (reporters and logs) 64 | colors: true, 65 | 66 | 67 | // level of logging 68 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 69 | logLevel: config.LOG_DEBUG, 70 | 71 | 72 | // enable / disable watching file and executing tests whenever any file changes 73 | autoWatch: true, 74 | 75 | 76 | // start these browsers 77 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 78 | browsers: ['Chrome'], 79 | 80 | 81 | // Continuous Integration mode 82 | // if true, Karma captures browsers, runs the tests and exits 83 | singleRun: false 84 | }); 85 | }; -------------------------------------------------------------------------------- /typings/es6-promise/es6-promise.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for es6-promise 2 | // Project: https://github.com/jakearchibald/ES6-Promise 3 | // Definitions by: François de Campredon , vvakame 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | interface Thenable { 7 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; 8 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; 9 | } 10 | 11 | declare class Promise implements Thenable { 12 | /** 13 | * If you call resolve in the body of the callback passed to the constructor, 14 | * your promise is fulfilled with result object passed to resolve. 15 | * If you call reject your promise is rejected with the object passed to resolve. 16 | * For consistency and debugging (eg stack traces), obj should be an instanceof Error. 17 | * Any errors thrown in the constructor callback will be implicitly passed to reject(). 18 | */ 19 | constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); 20 | 21 | /** 22 | * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. 23 | * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. 24 | * Both callbacks have a single parameter , the fulfillment value or rejection reason. 25 | * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. 26 | * If an error is thrown in the callback, the returned promise rejects with that error. 27 | * 28 | * @param onFulfilled called when/if "promise" resolves 29 | * @param onRejected called when/if "promise" rejects 30 | */ 31 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; 32 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; 33 | 34 | /** 35 | * Sugar for promise.then(undefined, onRejected) 36 | * 37 | * @param onRejected called when/if "promise" rejects 38 | */ 39 | catch(onRejected?: (error: any) => U | Thenable): Promise; 40 | } 41 | 42 | declare module Promise { 43 | /** 44 | * Make a new promise from the thenable. 45 | * A thenable is promise-like in as far as it has a "then" method. 46 | */ 47 | function resolve(value?: R | Thenable): Promise; 48 | 49 | /** 50 | * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error 51 | */ 52 | function reject(error: any): Promise; 53 | 54 | /** 55 | * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. 56 | * the array passed to all can be a mixture of promise-like objects and other objects. 57 | * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. 58 | */ 59 | function all(promises: (R | Thenable)[]): Promise; 60 | 61 | /** 62 | * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. 63 | */ 64 | function race(promises: (R | Thenable)[]): Promise; 65 | } 66 | 67 | declare module 'es6-promise' { 68 | var foo: typeof Promise; // Temp variable to reference Promise in local context 69 | module rsvp { 70 | export var Promise: typeof foo; 71 | } 72 | export = rsvp; 73 | } 74 | -------------------------------------------------------------------------------- /typings/rx/rx.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for RxJS v2.5.3 2 | // Project: http://rx.codeplex.com/ 3 | // Definitions by: gsino , Igor Oleinikov 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module Rx { 9 | export interface IScheduler { 10 | catch(handler: (exception: any) => boolean): IScheduler; 11 | catchException(handler: (exception: any) => boolean): IScheduler; 12 | } 13 | 14 | // Observer 15 | export interface Observer { 16 | checked(): Observer; 17 | } 18 | 19 | interface ObserverStatic { 20 | /** 21 | * Schedules the invocation of observer methods on the given scheduler. 22 | * @param scheduler Scheduler to schedule observer messages on. 23 | * @returns Observer whose messages are scheduled on the given scheduler. 24 | */ 25 | notifyOn(scheduler: IScheduler): Observer; 26 | } 27 | 28 | export interface Observable { 29 | observeOn(scheduler: IScheduler): Observable; 30 | subscribeOn(scheduler: IScheduler): Observable; 31 | 32 | amb(rightSource: Observable): Observable; 33 | amb(rightSource: IPromise): Observable; 34 | onErrorResumeNext(second: Observable): Observable; 35 | onErrorResumeNext(second: IPromise): Observable; 36 | bufferWithCount(count: number, skip?: number): Observable; 37 | windowWithCount(count: number, skip?: number): Observable>; 38 | defaultIfEmpty(defaultValue?: T): Observable; 39 | distinct(skipParameter: boolean, valueSerializer: (value: T) => string): Observable; 40 | distinct(keySelector?: (value: T) => TKey, keySerializer?: (key: TKey) => string): Observable; 41 | groupBy(keySelector: (value: T) => TKey, skipElementSelector?: boolean, keySerializer?: (key: TKey) => string): Observable>; 42 | groupBy(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable>; 43 | groupByUntil(keySelector: (value: T) => TKey, skipElementSelector: boolean, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; 44 | groupByUntil(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; 45 | } 46 | 47 | interface ObservableStatic { 48 | using(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable): Observable; 49 | amb(...sources: Observable[]): Observable; 50 | amb(...sources: IPromise[]): Observable; 51 | amb(sources: Observable[]): Observable; 52 | amb(sources: IPromise[]): Observable; 53 | onErrorResumeNext(...sources: Observable[]): Observable; 54 | onErrorResumeNext(...sources: IPromise[]): Observable; 55 | onErrorResumeNext(sources: Observable[]): Observable; 56 | onErrorResumeNext(sources: IPromise[]): Observable; 57 | } 58 | 59 | interface GroupedObservable extends Observable { 60 | key: TKey; 61 | underlyingObservable: Observable; 62 | } 63 | } 64 | 65 | declare module "rx" { 66 | export = Rx 67 | } 68 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var changed = require('gulp-changed'); 4 | var childProcess = require('child_process'); 5 | var del = require('del'); 6 | var gulp = require('gulp'); 7 | var runSequence = require('run-sequence'); 8 | var sourcemaps = require('gulp-sourcemaps'); 9 | var concat = require('gulp-concat'); 10 | var tsd = require('tsd'); 11 | var ts = require('gulp-typescript'); 12 | var tslint = require('gulp-tslint'); 13 | var minimist = require('minimist'); 14 | 15 | var packageJson = require('./package.json'); 16 | 17 | var spawn = childProcess.spawn; 18 | var server; 19 | 20 | var PATHS = { 21 | lib: [ 22 | 'node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js', 23 | 'node_modules/angular2/node_modules/rx/dist/rx.js', 24 | 'node_modules/reflect-metadata/Reflect.js', 25 | 'node_modules/zone.js/dist/zone.js', 26 | 'node_modules/zone.js/dist/long-stack-trace-zone.js', 27 | '!node_modules/systemjs/dist/*.src.js', 28 | 'node_modules/systemjs/dist/*.js' 29 | ], 30 | typings: [ 31 | 'typings/tsd.d.ts' 32 | ], 33 | client: { 34 | ts: ['client/**/*.ts'], 35 | html: 'client/**/*.html', 36 | css: 'client/**/*.css', 37 | img: 'client/**/*.{svg,jpg,png,ico}' 38 | }, 39 | dist: 'dist', 40 | distClient: 'dist/client', 41 | distLib: 'dist/lib', 42 | port: 8080 43 | }; 44 | 45 | var tsProject = ts.createProject('tsconfig.json', { 46 | typescript: require('typescript') 47 | }); 48 | 49 | gulp.task('clean', function(done) { 50 | del([PATHS.dist], done); 51 | }); 52 | 53 | gulp.task('tsd', function() { 54 | var tsdAPI = tsd.getAPI('tsd.json'); 55 | return tsdAPI.readConfig({}, true).then(function() { 56 | return tsdAPI.reinstall( 57 | tsd.Options.fromJSON({}) // https://github.com/DefinitelyTyped/tsd/blob/bb2dc91ad64f159298657805154259f9e68ea8a6/src/tsd/Options.ts 58 | ).then(function() { 59 | return tsdAPI.updateBundle(tsdAPI.context.config.bundle, true); 60 | }); 61 | }); 62 | }); 63 | 64 | gulp.task('angular2', function() { 65 | return gulp 66 | .src([ 67 | '!node_modules/angular2/es6/**', 68 | '!node_modules/angular2/node_modules/**', 69 | '!node_modules/angular2/angular2.api.js', 70 | '!node_modules/angular2/angular2_sfx.js', 71 | '!node_modules/angular2/angular2.api.js', 72 | '!node_modules/angular2/ts/**', 73 | 'node_modules/angular2/**/*.js' 74 | ]) 75 | .pipe(gulp.dest(PATHS.dist + '/lib/angular2')); 76 | }); 77 | 78 | gulp.task('libs', ['tsd', 'angular2'], function() { 79 | return gulp 80 | .src(PATHS.lib) 81 | .pipe(gulp.dest(PATHS.distLib)); 82 | }); 83 | 84 | gulp.task('ts', function() { 85 | return gulp 86 | .src([].concat(PATHS.typings, PATHS.client.ts)) // instead of gulp.src(...), project.src() can be used 87 | .pipe(changed(PATHS.distClient, { 88 | extension: '.js' 89 | })) 90 | .pipe(sourcemaps.init()) 91 | .pipe(ts(tsProject)) 92 | .pipe(sourcemaps.write('.')) 93 | .pipe(gulp.dest(PATHS.distClient)); 94 | }); 95 | 96 | gulp.task('lint', function () { // https://github.com/palantir/tslint#supported-rules 97 | return gulp 98 | .src(PATHS.client.ts) 99 | .pipe(tslint()) 100 | .pipe(tslint.report('prose', { 101 | emitError: false 102 | })); 103 | }); 104 | 105 | gulp.task('html', function() { 106 | return gulp 107 | .src(PATHS.client.html) 108 | .pipe(changed(PATHS.distClient)) 109 | .pipe(gulp.dest(PATHS.distClient)); 110 | }); 111 | 112 | gulp.task('css', function() { 113 | return gulp 114 | .src(PATHS.client.css) 115 | .pipe(changed(PATHS.distClient, { 116 | extension: '.css' 117 | })) 118 | .pipe(sourcemaps.init()) 119 | .pipe(concat('app.css')) 120 | .pipe(sourcemaps.write('.')) 121 | .pipe(gulp.dest(PATHS.distClient)); 122 | }); 123 | 124 | gulp.task('img', function() { 125 | return gulp 126 | .src(PATHS.client.img) 127 | .pipe(changed(PATHS.distClient)) 128 | .pipe(gulp.dest(PATHS.distClient)); 129 | }); 130 | 131 | gulp.task('bundle', function(done) { 132 | runSequence('clean', ['libs', 'lint', 'ts', 'html', 'css', 'img'], done); 133 | }); 134 | 135 | gulp.task('server:restart', function(done) { 136 | var started = false; 137 | if (server) { 138 | server.kill(); 139 | } 140 | var args = minimist(process.argv.slice(2), {default: {port: '8080'}}); 141 | server = spawn('node', [packageJson.main, '--port', args.port]); 142 | server.stdout.on('data', function(data) { 143 | console.log(data.toString()); 144 | if (started === false) { 145 | started = true; 146 | done(); 147 | } 148 | }); 149 | server.stderr.on('data', function(data) { 150 | console.error(data.toString()); 151 | }); 152 | }); 153 | 154 | // clean up if an error goes unhandled. 155 | process.on('exit', function() { 156 | if (server) { 157 | server.kill(); 158 | } 159 | }); 160 | 161 | gulp.task('go', ['bundle', 'server:restart'], function() { 162 | gulp.watch(PATHS.client.ts, ['ts']); 163 | gulp.watch(PATHS.client.html, ['html']); 164 | gulp.watch(PATHS.client.css, ['css']); 165 | gulp.watch(PATHS.client.img, ['img']); 166 | gulp.watch(packageJson.main, ['server:restart']); 167 | }); 168 | 169 | gulp.task('default', ['bundle']); 170 | -------------------------------------------------------------------------------- /typings/angular2/router.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Angular v2.0.0-alpha.37 2 | // Project: http://angular.io/ 3 | // Definitions by: angular team 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | // *********************************************************** 7 | // This file is generated by the Angular build process. 8 | // Please do not create manual edits or send pull requests 9 | // modifying this file. 10 | // *********************************************************** 11 | 12 | // angular2/router depends transitively on these libraries. 13 | // If you don't have them installed you can install them using TSD 14 | // https://github.com/DefinitelyTyped/tsd 15 | 16 | /// 17 | 18 | 19 | 20 | 21 | /** 22 | * @module 23 | * @description 24 | * Maps application URLs into application states, to support deep-linking and navigation. 25 | */ 26 | declare module ngRouter { 27 | 28 | /** 29 | * # Router 30 | * The router is responsible for mapping URLs to components. 31 | * 32 | * You can see the state of the router by inspecting the read-only field `router.navigating`. 33 | * This may be useful for showing a spinner, for instance. 34 | * 35 | * ## Concepts 36 | * Routers and component instances have a 1:1 correspondence. 37 | * 38 | * The router holds reference to a number of "outlets." An outlet is a placeholder that the 39 | * router dynamically fills in depending on the current URL. 40 | * 41 | * When the router navigates from a URL, it must first recognizes it and serialize it into an 42 | * `Instruction`. 43 | * The router uses the `RouteRegistry` to get an `Instruction`. 44 | */ 45 | class Router { 46 | 47 | navigating: boolean; 48 | 49 | lastNavigationAttempt: string; 50 | 51 | registry: RouteRegistry; 52 | 53 | parent: Router; 54 | 55 | hostComponent: any; 56 | 57 | 58 | /** 59 | * Constructs a child router. You probably don't need to use this unless you're writing a reusable 60 | * component. 61 | */ 62 | childRouter(hostComponent: any): Router; 63 | 64 | 65 | /** 66 | * Constructs a child router. You probably don't need to use this unless you're writing a reusable 67 | * component. 68 | */ 69 | auxRouter(hostComponent: any): Router; 70 | 71 | 72 | /** 73 | * Register an outlet to notified of primary route changes. 74 | * 75 | * You probably don't need to use this unless you're writing a reusable component. 76 | */ 77 | registerPrimaryOutlet(outlet: RouterOutlet): Promise; 78 | 79 | 80 | /** 81 | * Register an outlet to notified of auxiliary route changes. 82 | * 83 | * You probably don't need to use this unless you're writing a reusable component. 84 | */ 85 | registerAuxOutlet(outlet: RouterOutlet): Promise; 86 | 87 | 88 | /** 89 | * Given an instruction, returns `true` if the instruction is currently active, 90 | * otherwise `false`. 91 | */ 92 | isRouteActive(instruction: Instruction): boolean; 93 | 94 | 95 | /** 96 | * Dynamically update the routing configuration and trigger a navigation. 97 | * 98 | * # Usage 99 | * 100 | * ``` 101 | * router.config([ 102 | * { 'path': '/', 'component': IndexComp }, 103 | * { 'path': '/user/:id', 'component': UserComp }, 104 | * ]); 105 | * ``` 106 | */ 107 | config(definitions: RouteDefinition[]): Promise; 108 | 109 | 110 | /** 111 | * Navigate to a URL. Returns a promise that resolves when navigation is complete. 112 | * 113 | * If the given URL begins with a `/`, router will navigate absolutely. 114 | * If the given URL does not begin with `/`, the router will navigate relative to this component. 115 | */ 116 | navigate(url: string, _skipLocationChange?: boolean): Promise; 117 | 118 | 119 | /** 120 | * Navigate via the provided instruction. Returns a promise that resolves when navigation is 121 | * complete. 122 | */ 123 | navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise; 124 | 125 | 126 | /** 127 | * Updates this router and all descendant routers according to the given instruction 128 | */ 129 | commit(instruction: Instruction, _skipLocationChange?: boolean): Promise; 130 | 131 | 132 | /** 133 | * Subscribe to URL updates from the router 134 | */ 135 | subscribe(onNext: (value: any) => void): Object; 136 | 137 | 138 | /** 139 | * Removes the contents of this router's outlet and all descendant outlets 140 | */ 141 | deactivate(instruction: Instruction): Promise; 142 | 143 | 144 | /** 145 | * Given a URL, returns an instruction representing the component graph 146 | */ 147 | recognize(url: string): Promise; 148 | 149 | 150 | /** 151 | * Navigates to either the last URL successfully navigated to, or the last URL requested if the 152 | * router has yet to successfully navigate. 153 | */ 154 | renavigate(): Promise; 155 | 156 | 157 | /** 158 | * Generate a URL from a component name and optional map of parameters. The URL is relative to the 159 | * app's base href. 160 | */ 161 | generate(linkParams: any[]): Instruction; 162 | } 163 | 164 | class RootRouter extends Router { 165 | 166 | commit(instruction: Instruction, _skipLocationChange?: boolean): Promise; 167 | } 168 | 169 | 170 | /** 171 | * A router outlet is a placeholder that Angular dynamically fills based on the application's route. 172 | * 173 | * ## Use 174 | * 175 | * ``` 176 | * 177 | * ``` 178 | */ 179 | class RouterOutlet { 180 | 181 | name: string; 182 | 183 | 184 | /** 185 | * Called by the Router to instantiate a new component during the commit phase of a navigation. 186 | * This method in turn is responsible for calling the `onActivate` hook of its child. 187 | */ 188 | activate(nextInstruction: ComponentInstruction): Promise; 189 | 190 | 191 | /** 192 | * Called by the {@link Router} during the commit phase of a navigation when an outlet 193 | * reuses a component between different routes. 194 | * This method in turn is responsible for calling the `onReuse` hook of its child. 195 | */ 196 | reuse(nextInstruction: ComponentInstruction): Promise; 197 | 198 | 199 | /** 200 | * Called by the {@link Router} when an outlet reuses a component across navigations. 201 | * This method in turn is responsible for calling the `onReuse` hook of its child. 202 | */ 203 | deactivate(nextInstruction: ComponentInstruction): Promise; 204 | 205 | 206 | /** 207 | * Called by the {@link Router} during recognition phase of a navigation. 208 | * 209 | * If this resolves to `false`, the given navigation is cancelled. 210 | * 211 | * This method delegates to the child component's `canDeactivate` hook if it exists, 212 | * and otherwise resolves to true. 213 | */ 214 | canDeactivate(nextInstruction: ComponentInstruction): Promise; 215 | 216 | 217 | /** 218 | * Called by the {@link Router} during recognition phase of a navigation. 219 | * 220 | * If the new child component has a different Type than the existing child component, 221 | * this will resolve to `false`. You can't reuse an old component when the new component 222 | * is of a different Type. 223 | * 224 | * Otherwise, this method delegates to the child component's `canReuse` hook if it exists, 225 | * or resolves to true if the hook is not present. 226 | */ 227 | canReuse(nextInstruction: ComponentInstruction): Promise; 228 | } 229 | 230 | 231 | /** 232 | * The RouterLink directive lets you link to specific parts of your app. 233 | * 234 | * Consider the following route configuration: 235 | * 236 | * ``` 237 | * @RouteConfig([ 238 | * { path: '/user', component: UserCmp, as: 'user' } 239 | * ]); 240 | * class MyComp {} 241 | * ``` 242 | * 243 | * When linking to this `user` route, you can write: 244 | * 245 | * ``` 246 | * link to user component 247 | * ``` 248 | * 249 | * RouterLink expects the value to be an array of route names, followed by the params 250 | * for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]` 251 | * means that we want to generate a link for the `team` route with params `{teamId: 1}`, 252 | * and with a child route `user` with params `{userId: 2}`. 253 | * 254 | * The first route name should be prepended with `/`, `./`, or `../`. 255 | * If the route begins with `/`, the router will look up the route from the root of the app. 256 | * If the route begins with `./`, the router will instead look in the current component's 257 | * children for the route. And if the route begins with `../`, the router will look at the 258 | * current component's parent. 259 | */ 260 | class RouterLink { 261 | 262 | visibleHref: string; 263 | 264 | isRouteActive: boolean; 265 | 266 | routeParams: any; 267 | 268 | onClick(): boolean; 269 | } 270 | 271 | class RouteParams { 272 | 273 | params: StringMap; 274 | 275 | get(param: string): string; 276 | } 277 | 278 | 279 | /** 280 | * The RouteRegistry holds route configurations for each component in an Angular app. 281 | * It is responsible for creating Instructions from URLs, and generating URLs based on route and 282 | * parameters. 283 | */ 284 | class RouteRegistry { 285 | 286 | 287 | /** 288 | * Given a component and a configuration object, add the route to this registry 289 | */ 290 | config(parentComponent: any, config: RouteDefinition): void; 291 | 292 | 293 | /** 294 | * Reads the annotations of a component and configures the registry based on them 295 | */ 296 | configFromComponent(component: any): void; 297 | 298 | 299 | /** 300 | * Given a URL and a parent component, return the most specific instruction for navigating 301 | * the application into the state specified by the url 302 | */ 303 | recognize(url: string, parentComponent: any): Promise; 304 | 305 | 306 | /** 307 | * Given a normalized list with component names and params like: `['user', {id: 3 }]` 308 | * generates a url with a leading slash relative to the provided `parentComponent`. 309 | */ 310 | generate(linkParams: any[], parentComponent: any): Instruction; 311 | } 312 | 313 | class LocationStrategy { 314 | 315 | path(): string; 316 | 317 | pushState(ctx: any, title: string, url: string): void; 318 | 319 | forward(): void; 320 | 321 | back(): void; 322 | 323 | onPopState(fn: (_: any) => any): void; 324 | 325 | getBaseHref(): string; 326 | } 327 | 328 | class HashLocationStrategy extends LocationStrategy { 329 | 330 | onPopState(fn: EventListener): void; 331 | 332 | getBaseHref(): string; 333 | 334 | path(): string; 335 | 336 | pushState(state: any, title: string, url: string): void; 337 | 338 | forward(): void; 339 | 340 | back(): void; 341 | } 342 | 343 | class PathLocationStrategy extends LocationStrategy { 344 | 345 | onPopState(fn: EventListener): void; 346 | 347 | getBaseHref(): string; 348 | 349 | path(): string; 350 | 351 | pushState(state: any, title: string, url: string): void; 352 | 353 | forward(): void; 354 | 355 | back(): void; 356 | } 357 | 358 | 359 | /** 360 | * This is the service that an application developer will directly interact with. 361 | * 362 | * Responsible for normalizing the URL against the application's base href. 363 | * A normalized URL is absolute from the URL host, includes the application's base href, and has no 364 | * trailing slash: 365 | * - `/my/app/user/123` is normalized 366 | * - `my/app/user/123` **is not** normalized 367 | * - `/my/app/user/123/` **is not** normalized 368 | */ 369 | class Location { 370 | 371 | platformStrategy: LocationStrategy; 372 | 373 | path(): string; 374 | 375 | normalize(url: string): string; 376 | 377 | normalizeAbsolutely(url: string): string; 378 | 379 | go(url: string): void; 380 | 381 | forward(): void; 382 | 383 | back(): void; 384 | 385 | subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void; 386 | } 387 | 388 | const APP_BASE_HREF : OpaqueToken ; 389 | 390 | 391 | /** 392 | * Responsible for performing each step of navigation. 393 | * "Steps" are conceptually similar to "middleware" 394 | */ 395 | class Pipeline { 396 | 397 | steps: Function[]; 398 | 399 | process(instruction: Instruction): Promise; 400 | } 401 | 402 | 403 | /** 404 | * Defines route lifecycle method [onActivate], which is called by the router at the end of a 405 | * successful route navigation. 406 | * 407 | * For a single component's navigation, only one of either [onActivate] or [onReuse] will be called, 408 | * depending on the result of [canReuse]. 409 | * 410 | * If `onActivate` returns a promise, the route change will wait until the promise settles to 411 | * instantiate and activate child components. 412 | * 413 | * ## Example 414 | * ``` 415 | * @Directive({ 416 | * selector: 'my-cmp' 417 | * }) 418 | * class MyCmp implements OnActivate { 419 | * onActivate(next, prev) { 420 | * this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath; 421 | * } 422 | * } 423 | * ``` 424 | */ 425 | interface OnActivate { 426 | 427 | onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any; 428 | } 429 | 430 | 431 | /** 432 | * Defines route lifecycle method [onDeactivate], which is called by the router before destroying 433 | * a component as part of a route change. 434 | * 435 | * If `onDeactivate` returns a promise, the route change will wait until the promise settles. 436 | * 437 | * ## Example 438 | * ``` 439 | * @Directive({ 440 | * selector: 'my-cmp' 441 | * }) 442 | * class MyCmp implements CanReuse, OnReuse { 443 | * canReuse() { 444 | * return true; 445 | * } 446 | * 447 | * onReuse(next, prev) { 448 | * this.params = next.params; 449 | * } 450 | * } 451 | * ``` 452 | */ 453 | interface OnDeactivate { 454 | 455 | onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any; 456 | } 457 | 458 | 459 | /** 460 | * Defines route lifecycle method [onReuse], which is called by the router at the end of a 461 | * successful route navigation when [canReuse] is implemented and returns or resolves to true. 462 | * 463 | * For a single component's navigation, only one of either [onActivate] or [onReuse] will be called, 464 | * depending on the result of [canReuse]. 465 | * 466 | * ## Example 467 | * ``` 468 | * @Directive({ 469 | * selector: 'my-cmp' 470 | * }) 471 | * class MyCmp implements CanReuse, OnReuse { 472 | * canReuse() { 473 | * return true; 474 | * } 475 | * 476 | * onReuse(next, prev) { 477 | * this.params = next.params; 478 | * } 479 | * } 480 | * ``` 481 | */ 482 | interface OnReuse { 483 | 484 | onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any; 485 | } 486 | 487 | 488 | /** 489 | * Defines route lifecycle method [canDeactivate], which is called by the router to determine 490 | * if a component can be removed as part of a navigation. 491 | * 492 | * If `canDeactivate` returns or resolves to `false`, the navigation is cancelled. 493 | * 494 | * If `canDeactivate` throws or rejects, the navigation is also cancelled. 495 | * 496 | * ## Example 497 | * ``` 498 | * @Directive({ 499 | * selector: 'my-cmp' 500 | * }) 501 | * class MyCmp implements CanDeactivate { 502 | * canDeactivate(next, prev) { 503 | * return askUserIfTheyAreSureTheyWantToQuit(); 504 | * } 505 | * } 506 | * ``` 507 | */ 508 | interface CanDeactivate { 509 | 510 | canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any; 511 | } 512 | 513 | 514 | /** 515 | * Defines route lifecycle method [canReuse], which is called by the router to determine whether a 516 | * component should be reused across routes, or whether to destroy and instantiate a new component. 517 | * 518 | * If `canReuse` returns or resolves to `true`, the component instance will be reused. 519 | * 520 | * If `canReuse` throws or rejects, the navigation will be cancelled. 521 | * 522 | * ## Example 523 | * ``` 524 | * @Directive({ 525 | * selector: 'my-cmp' 526 | * }) 527 | * class MyCmp implements CanReuse, OnReuse { 528 | * canReuse(next, prev) { 529 | * return next.params.id == prev.params.id; 530 | * } 531 | * 532 | * onReuse(next, prev) { 533 | * this.id = next.params.id; 534 | * } 535 | * } 536 | * ``` 537 | */ 538 | interface CanReuse { 539 | 540 | canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any; 541 | } 542 | 543 | 544 | /** 545 | * Defines route lifecycle method [canActivate], which is called by the router to determine 546 | * if a component can be instantiated as part of a navigation. 547 | * 548 | * Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface. 549 | * This is because [canActivate] is called before the component is instantiated. 550 | * 551 | * If `canActivate` returns or resolves to `false`, the navigation is cancelled. 552 | * 553 | * If `canActivate` throws or rejects, the navigation is also cancelled. 554 | * 555 | * ## Example 556 | * ``` 557 | * @Directive({ 558 | * selector: 'control-panel-cmp' 559 | * }) 560 | * @CanActivate(() => checkIfUserIsLoggedIn()) 561 | * class ControlPanelCmp { 562 | * // ... 563 | * } 564 | * ``` 565 | */ 566 | var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise| boolean) => 567 | ClassDecorator ; 568 | 569 | 570 | /** 571 | * `Instruction` is a tree of `ComponentInstructions`, with all the information needed 572 | * to transition each component in the app to a given route, including all auxiliary routes. 573 | * 574 | * This is a public API. 575 | */ 576 | class Instruction { 577 | 578 | component: ComponentInstruction; 579 | 580 | child: Instruction; 581 | 582 | auxInstruction: StringMap; 583 | 584 | replaceChild(child: Instruction): Instruction; 585 | } 586 | 587 | 588 | /** 589 | * A `ComponentInstruction` represents the route state for a single component. An `Instruction` is 590 | * composed of a tree of these `ComponentInstruction`s. 591 | * 592 | * `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed 593 | * to route lifecycle hooks, like {@link CanActivate}. 594 | * 595 | * `ComponentInstruction`s are [https://en.wikipedia.org/wiki/Hash_consing](hash consed). You should 596 | * never construct one yourself with "new." Instead, rely on {@link PathRecognizer} to construct 597 | * `ComponentInstruction`s. 598 | * 599 | * You should not modify this object. It should be treated as immutable. 600 | */ 601 | class ComponentInstruction { 602 | 603 | reuse: boolean; 604 | 605 | urlPath: string; 606 | 607 | urlParams: string[]; 608 | 609 | params: StringMap; 610 | 611 | componentType: any; 612 | 613 | resolveComponentType(): Promise; 614 | 615 | specificity: any; 616 | 617 | terminal: any; 618 | 619 | routeData(): Object; 620 | } 621 | 622 | 623 | /** 624 | * This class represents a parsed URL 625 | */ 626 | class Url { 627 | 628 | path: string; 629 | 630 | child: Url; 631 | 632 | auxiliary: Url[]; 633 | 634 | params: StringMap; 635 | 636 | toString(): string; 637 | 638 | segmentToString(): string; 639 | } 640 | 641 | class OpaqueToken { 642 | 643 | toString(): string; 644 | } 645 | 646 | const ROUTE_DATA : OpaqueToken ; 647 | 648 | const ROUTER_DIRECTIVES : any[] ; 649 | 650 | const ROUTER_BINDINGS : any[] ; 651 | 652 | class Route implements RouteDefinition { 653 | 654 | data: any; 655 | 656 | path: string; 657 | 658 | component: ng.Type; 659 | 660 | as: string; 661 | 662 | loader: Function; 663 | 664 | redirectTo: string; 665 | } 666 | 667 | class Redirect implements RouteDefinition { 668 | 669 | path: string; 670 | 671 | redirectTo: string; 672 | 673 | as: string; 674 | 675 | loader: Function; 676 | 677 | data: any; 678 | } 679 | 680 | class AuxRoute implements RouteDefinition { 681 | 682 | data: any; 683 | 684 | path: string; 685 | 686 | component: ng.Type; 687 | 688 | as: string; 689 | 690 | loader: Function; 691 | 692 | redirectTo: string; 693 | } 694 | 695 | class AsyncRoute implements RouteDefinition { 696 | 697 | data: any; 698 | 699 | path: string; 700 | 701 | loader: Function; 702 | 703 | as: string; 704 | } 705 | 706 | interface RouteDefinition { 707 | 708 | path: string; 709 | 710 | component?: ng.Type | ComponentDefinition; 711 | 712 | loader?: Function; 713 | 714 | redirectTo?: string; 715 | 716 | as?: string; 717 | 718 | data?: any; 719 | } 720 | 721 | var RouteConfig : (configs: RouteDefinition[]) => ClassDecorator ; 722 | 723 | interface ComponentDefinition { 724 | 725 | type: string; 726 | 727 | loader?: Function; 728 | 729 | component?: ng.Type; 730 | } 731 | 732 | } 733 | 734 | declare module "angular2/router" { 735 | export = ngRouter; 736 | } 737 | -------------------------------------------------------------------------------- /typings/angular2/http.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Angular v2.0.0-alpha.37 2 | // Project: http://angular.io/ 3 | // Definitions by: angular team 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | // *********************************************************** 7 | // This file is generated by the Angular build process. 8 | // Please do not create manual edits or send pull requests 9 | // modifying this file. 10 | // *********************************************************** 11 | 12 | // angular2/http depends transitively on these libraries. 13 | // If you don't have them installed you can install them using TSD 14 | // https://github.com/DefinitelyTyped/tsd 15 | 16 | /// 17 | 18 | 19 | 20 | 21 | /** 22 | * @module 23 | * @description 24 | * The http module provides services to perform http requests. To get started, see the {@link Http} 25 | * class. 26 | */ 27 | declare module ngHttp { 28 | 29 | /** 30 | * Mock Connection to represent a {@link Connection} for tests. 31 | */ 32 | class MockConnection implements Connection { 33 | 34 | 35 | /** 36 | * Describes the state of the connection, based on `XMLHttpRequest.readyState`, but with 37 | * additional states. For example, state 5 indicates an aborted connection. 38 | */ 39 | readyState: ReadyStates; 40 | 41 | 42 | /** 43 | * {@link Request} instance used to create the connection. 44 | */ 45 | request: Request; 46 | 47 | 48 | /** 49 | * {@link EventEmitter} of {@link Response}. Can be subscribed to in order to be notified when a 50 | * response is available. 51 | */ 52 | response: ng.EventEmitter; 53 | 54 | 55 | /** 56 | * Changes the `readyState` of the connection to a custom state of 5 (cancelled). 57 | */ 58 | dispose(): void; 59 | 60 | 61 | /** 62 | * Sends a mock response to the connection. This response is the value that is emitted to the 63 | * {@link EventEmitter} returned by {@link Http}. 64 | * 65 | * #Example 66 | * 67 | * ``` 68 | * var connection; 69 | * backend.connections.subscribe(c => connection = c); 70 | * http.request('data.json').subscribe(res => console.log(res.text())); 71 | * connection.mockRespond(new Response('fake response')); //logs 'fake response' 72 | * ``` 73 | */ 74 | mockRespond(res: Response): void; 75 | 76 | 77 | /** 78 | * Not yet implemented! 79 | * 80 | * Sends the provided {@link Response} to the `downloadObserver` of the `Request` 81 | * associated with this connection. 82 | */ 83 | mockDownload(res: Response): void; 84 | 85 | 86 | /** 87 | * Emits the provided error object as an error to the {@link Response} {@link EventEmitter} 88 | * returned 89 | * from {@link Http}. 90 | */ 91 | mockError(err?: Error): void; 92 | } 93 | 94 | 95 | /** 96 | * A mock backend for testing the {@link Http} service. 97 | * 98 | * This class can be injected in tests, and should be used to override bindings 99 | * to other backends, such as {@link XHRBackend}. 100 | * 101 | * #Example 102 | * 103 | * ``` 104 | * import {MockBackend, DefaultOptions, Http} from 'angular2/http'; 105 | * it('should get some data', inject([AsyncTestCompleter], (async) => { 106 | * var connection; 107 | * var injector = Injector.resolveAndCreate([ 108 | * MockBackend, 109 | * bind(Http).toFactory((backend, defaultOptions) => { 110 | * return new Http(backend, defaultOptions) 111 | * }, [MockBackend, DefaultOptions])]); 112 | * var http = injector.get(Http); 113 | * var backend = injector.get(MockBackend); 114 | * //Assign any newly-created connection to local variable 115 | * backend.connections.subscribe(c => connection = c); 116 | * http.request('data.json').subscribe((res) => { 117 | * expect(res.text()).toBe('awesome'); 118 | * async.done(); 119 | * }); 120 | * connection.mockRespond(new Response('awesome')); 121 | * })); 122 | * ``` 123 | * 124 | * This method only exists in the mock implementation, not in real Backends. 125 | */ 126 | class MockBackend implements ConnectionBackend { 127 | 128 | 129 | /** 130 | * {@link EventEmitter} 131 | * of {@link MockConnection} instances that have been created by this backend. Can be subscribed 132 | * to in order to respond to connections. 133 | * 134 | * #Example 135 | * 136 | * ``` 137 | * import {MockBackend, Http, BaseRequestOptions} from 'angular2/http'; 138 | * import {Injector} from 'angular2/di'; 139 | * 140 | * it('should get a response', () => { 141 | * var connection; //this will be set when a new connection is emitted from the backend. 142 | * var text; //this will be set from mock response 143 | * var injector = Injector.resolveAndCreate([ 144 | * MockBackend, 145 | * bind(Http).toFactory(backend, options) { 146 | * return new Http(backend, options); 147 | * }, [MockBackend, BaseRequestOptions]]); 148 | * var backend = injector.get(MockBackend); 149 | * var http = injector.get(Http); 150 | * backend.connections.subscribe(c => connection = c); 151 | * http.request('something.json').subscribe(res => { 152 | * text = res.text(); 153 | * }); 154 | * connection.mockRespond(new Response({body: 'Something'})); 155 | * expect(text).toBe('Something'); 156 | * }); 157 | * ``` 158 | * 159 | * This property only exists in the mock implementation, not in real Backends. 160 | */ 161 | connections: ng.EventEmitter; 162 | 163 | 164 | /** 165 | * An array representation of `connections`. This array will be updated with each connection that 166 | * is created by this backend. 167 | * 168 | * This property only exists in the mock implementation, not in real Backends. 169 | */ 170 | connectionsArray: MockConnection[]; 171 | 172 | 173 | /** 174 | * {@link EventEmitter} of {@link MockConnection} instances that haven't yet been resolved (i.e. 175 | * with a `readyState` 176 | * less than 4). Used internally to verify that no connections are pending via the 177 | * `verifyNoPendingRequests` method. 178 | * 179 | * This property only exists in the mock implementation, not in real Backends. 180 | */ 181 | pendingConnections: ng.EventEmitter; 182 | 183 | 184 | /** 185 | * Checks all connections, and raises an exception if any connection has not received a response. 186 | * 187 | * This method only exists in the mock implementation, not in real Backends. 188 | */ 189 | verifyNoPendingRequests(): void; 190 | 191 | 192 | /** 193 | * Can be used in conjunction with `verifyNoPendingRequests` to resolve any not-yet-resolve 194 | * connections, if it's expected that there are connections that have not yet received a response. 195 | * 196 | * This method only exists in the mock implementation, not in real Backends. 197 | */ 198 | resolveAllConnections(): void; 199 | 200 | 201 | /** 202 | * Creates a new {@link MockConnection}. This is equivalent to calling `new 203 | * MockConnection()`, except that it also will emit the new `Connection` to the `connections` 204 | * emitter of this `MockBackend` instance. This method will usually only be used by tests 205 | * against the framework itself, not by end-users. 206 | */ 207 | createConnection(req: Request): Connection; 208 | } 209 | 210 | 211 | /** 212 | * Creates `Request` instances from provided values. 213 | * 214 | * The Request's interface is inspired by the Request constructor defined in the [Fetch 215 | * Spec](https://fetch.spec.whatwg.org/#request-class), 216 | * but is considered a static value whose body can be accessed many times. There are other 217 | * differences in the implementation, but this is the most significant. 218 | */ 219 | class Request { 220 | 221 | 222 | /** 223 | * Http method with which to perform the request. 224 | * 225 | * Defaults to GET. 226 | */ 227 | method: RequestMethods; 228 | 229 | mode: RequestModesOpts; 230 | 231 | credentials: RequestCredentialsOpts; 232 | 233 | 234 | /** 235 | * Headers object based on the `Headers` class in the [Fetch 236 | * Spec](https://fetch.spec.whatwg.org/#headers-class). {@link Headers} class reference. 237 | */ 238 | headers: Headers; 239 | 240 | 241 | /** 242 | * Url of the remote resource 243 | */ 244 | url: string; 245 | 246 | cache: RequestCacheOpts; 247 | 248 | 249 | /** 250 | * Returns the request's body as string, assuming that body exists. If body is undefined, return 251 | * empty 252 | * string. 253 | */ 254 | text(): String; 255 | } 256 | 257 | 258 | /** 259 | * Creates `Response` instances from provided values. 260 | * 261 | * Though this object isn't 262 | * usually instantiated by end-users, it is the primary object interacted with when it comes time to 263 | * add data to a view. 264 | * 265 | * #Example 266 | * 267 | * ``` 268 | * http.request('my-friends.txt').subscribe(response => this.friends = response.text()); 269 | * ``` 270 | * 271 | * The Response's interface is inspired by the Response constructor defined in the [Fetch 272 | * Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body 273 | * can be accessed many times. There are other differences in the implementation, but this is the 274 | * most significant. 275 | */ 276 | class Response { 277 | 278 | 279 | /** 280 | * One of "basic", "cors", "default", "error, or "opaque". 281 | * 282 | * Defaults to "default". 283 | */ 284 | type: ResponseTypes; 285 | 286 | 287 | /** 288 | * True if the response's status is within 200-299 289 | */ 290 | ok: boolean; 291 | 292 | 293 | /** 294 | * URL of response. 295 | * 296 | * Defaults to empty string. 297 | */ 298 | url: string; 299 | 300 | 301 | /** 302 | * Status code returned by server. 303 | * 304 | * Defaults to 200. 305 | */ 306 | status: number; 307 | 308 | 309 | /** 310 | * Text representing the corresponding reason phrase to the `status`, as defined in [ietf rfc 2616 311 | * section 6.1.1](https://tools.ietf.org/html/rfc2616#section-6.1.1) 312 | * 313 | * Defaults to "OK" 314 | */ 315 | statusText: string; 316 | 317 | 318 | /** 319 | * Non-standard property 320 | * 321 | * Denotes how many of the response body's bytes have been loaded, for example if the response is 322 | * the result of a progress event. 323 | */ 324 | bytesLoaded: number; 325 | 326 | 327 | /** 328 | * Non-standard property 329 | * 330 | * Denotes how many bytes are expected in the final response body. 331 | */ 332 | totalBytes: number; 333 | 334 | 335 | /** 336 | * Headers object based on the `Headers` class in the [Fetch 337 | * Spec](https://fetch.spec.whatwg.org/#headers-class). 338 | */ 339 | headers: Headers; 340 | 341 | 342 | /** 343 | * Not yet implemented 344 | */ 345 | blob(): any; 346 | 347 | 348 | /** 349 | * Attempts to return body as parsed `JSON` object, or raises an exception. 350 | */ 351 | json(): Object; 352 | 353 | 354 | /** 355 | * Returns the body as a string, presuming `toString()` can be called on the response body. 356 | */ 357 | text(): string; 358 | 359 | 360 | /** 361 | * Not yet implemented 362 | */ 363 | arrayBuffer(): any; 364 | } 365 | 366 | 367 | /** 368 | * Interface for options to construct a Request, based on 369 | * [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec. 370 | */ 371 | interface RequestOptionsArgs { 372 | 373 | url?: string; 374 | 375 | method?: RequestMethods; 376 | 377 | search?: string | URLSearchParams; 378 | 379 | headers?: Headers; 380 | 381 | body?: string; 382 | 383 | mode?: RequestModesOpts; 384 | 385 | credentials?: RequestCredentialsOpts; 386 | 387 | cache?: RequestCacheOpts; 388 | } 389 | 390 | 391 | /** 392 | * Interface for options to construct a Response, based on 393 | * [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec. 394 | */ 395 | interface ResponseOptionsArgs { 396 | 397 | body?: string | Object | FormData; 398 | 399 | status?: number; 400 | 401 | statusText?: string; 402 | 403 | headers?: Headers; 404 | 405 | type?: ResponseTypes; 406 | 407 | url?: string; 408 | } 409 | 410 | 411 | /** 412 | * Abstract class from which real connections are derived. 413 | */ 414 | class Connection { 415 | 416 | readyState: ReadyStates; 417 | 418 | request: Request; 419 | 420 | response: ng.EventEmitter; 421 | 422 | dispose(): void; 423 | } 424 | 425 | 426 | /** 427 | * Abstract class from which real backends are derived. 428 | * 429 | * The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given 430 | * {@link Request}. 431 | */ 432 | class ConnectionBackend { 433 | 434 | createConnection(request: any): Connection; 435 | } 436 | 437 | class BrowserXhr { 438 | 439 | build(): any; 440 | } 441 | 442 | 443 | /** 444 | * Injectable version of {@link RequestOptions}, with overridable default values. 445 | * 446 | * #Example 447 | * 448 | * ``` 449 | * import {Http, BaseRequestOptions, Request} from 'angular2/http'; 450 | * ... 451 | * class MyComponent { 452 | * constructor(baseRequestOptions:BaseRequestOptions, http:Http) { 453 | * var options = baseRequestOptions.merge({body: 'foobar', url: 'https://foo'}); 454 | * var request = new Request(options); 455 | * http.request(request).subscribe(res => this.bars = res.json()); 456 | * } 457 | * } 458 | * 459 | * ``` 460 | */ 461 | class BaseRequestOptions extends RequestOptions { 462 | } 463 | 464 | 465 | /** 466 | * Creates a request options object similar to the `RequestInit` description 467 | * in the [Fetch 468 | * Spec](https://fetch.spec.whatwg.org/#requestinit) to be optionally provided when instantiating a 469 | * {@link Request}. 470 | * 471 | * All values are null by default. 472 | */ 473 | class RequestOptions { 474 | 475 | 476 | /** 477 | * Http method with which to execute the request. 478 | * 479 | * Defaults to "GET". 480 | */ 481 | method: RequestMethods; 482 | 483 | 484 | /** 485 | * Headers object based on the `Headers` class in the [Fetch 486 | * Spec](https://fetch.spec.whatwg.org/#headers-class). 487 | */ 488 | headers: Headers; 489 | 490 | 491 | /** 492 | * Body to be used when creating the request. 493 | */ 494 | body: string; 495 | 496 | mode: RequestModesOpts; 497 | 498 | credentials: RequestCredentialsOpts; 499 | 500 | cache: RequestCacheOpts; 501 | 502 | url: string; 503 | 504 | search: URLSearchParams; 505 | 506 | 507 | /** 508 | * Creates a copy of the `RequestOptions` instance, using the optional input as values to override 509 | * existing values. 510 | */ 511 | merge(options?: RequestOptionsArgs): RequestOptions; 512 | } 513 | 514 | 515 | /** 516 | * Injectable version of {@link ResponseOptions}, with overridable default values. 517 | */ 518 | class BaseResponseOptions extends ResponseOptions { 519 | 520 | body: string | Object | ArrayBuffer | JSON | FormData | Blob; 521 | 522 | status: number; 523 | 524 | headers: Headers; 525 | 526 | statusText: string; 527 | 528 | type: ResponseTypes; 529 | 530 | url: string; 531 | } 532 | 533 | 534 | /** 535 | * Creates a response options object similar to the 536 | * [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) description 537 | * in the Fetch 538 | * Spec to be optionally provided when instantiating a 539 | * {@link Response}. 540 | * 541 | * All values are null by default. 542 | */ 543 | class ResponseOptions { 544 | 545 | body: string | Object; 546 | 547 | status: number; 548 | 549 | headers: Headers; 550 | 551 | statusText: string; 552 | 553 | type: ResponseTypes; 554 | 555 | url: string; 556 | 557 | merge(options?: ResponseOptionsArgs): ResponseOptions; 558 | } 559 | 560 | 561 | /** 562 | * Creates {@link XHRConnection} instances. 563 | * 564 | * This class would typically not be used by end users, but could be 565 | * overridden if a different backend implementation should be used, 566 | * such as in a node backend. 567 | * 568 | * #Example 569 | * 570 | * ``` 571 | * import {Http, MyNodeBackend, HTTP_BINDINGS, BaseRequestOptions} from 'angular2/http'; 572 | * @Component({ 573 | * viewBindings: [ 574 | * HTTP_BINDINGS, 575 | * bind(Http).toFactory((backend, options) => { 576 | * return new Http(backend, options); 577 | * }, [MyNodeBackend, BaseRequestOptions])] 578 | * }) 579 | * class MyComponent { 580 | * constructor(http:Http) { 581 | * http('people.json').subscribe(res => this.people = res.json()); 582 | * } 583 | * } 584 | * ``` 585 | */ 586 | class XHRBackend implements ConnectionBackend { 587 | 588 | createConnection(request: Request): XHRConnection; 589 | } 590 | 591 | 592 | /** 593 | * Creates connections using `XMLHttpRequest`. Given a fully-qualified 594 | * request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the 595 | * request. 596 | * 597 | * This class would typically not be created or interacted with directly inside applications, though 598 | * the {@link MockConnection} may be interacted with in tests. 599 | */ 600 | class XHRConnection implements Connection { 601 | 602 | request: Request; 603 | 604 | 605 | /** 606 | * Response {@link EventEmitter} which emits a single {@link Response} value on load event of 607 | * `XMLHttpRequest`. 608 | */ 609 | response: ng.EventEmitter; 610 | 611 | readyState: ReadyStates; 612 | 613 | 614 | /** 615 | * Calls abort on the underlying XMLHttpRequest. 616 | */ 617 | dispose(): void; 618 | } 619 | 620 | class JSONPBackend implements ConnectionBackend { 621 | 622 | createConnection(request: Request): JSONPConnection; 623 | } 624 | 625 | class JSONPConnection implements Connection { 626 | 627 | readyState: ReadyStates; 628 | 629 | request: Request; 630 | 631 | response: ng.EventEmitter; 632 | 633 | baseResponseOptions: ResponseOptions; 634 | 635 | finished(data?: any): void; 636 | 637 | dispose(): void; 638 | } 639 | 640 | 641 | /** 642 | * Performs http requests using `XMLHttpRequest` as the default backend. 643 | * 644 | * `Http` is available as an injectable class, with methods to perform http requests. Calling 645 | * `request` returns an {@link EventEmitter} which will emit a single {@link Response} when a 646 | * response is received. 647 | * 648 | * 649 | * ## Breaking Change 650 | * 651 | * Previously, methods of `Http` would return an RxJS Observable directly. For now, 652 | * the `toRx()` method of {@link EventEmitter} needs to be called in order to get the RxJS 653 | * Subject. `EventEmitter` does not provide combinators like `map`, and has different semantics for 654 | * subscribing/observing. This is temporary; the result of all `Http` method calls will be either an 655 | * Observable 656 | * or Dart Stream when [issue #2794](https://github.com/angular/angular/issues/2794) is resolved. 657 | * 658 | * #Example 659 | * 660 | * ``` 661 | * import {Http, HTTP_BINDINGS} from 'angular2/http'; 662 | * @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]}) 663 | * @View({templateUrl: 'people.html'}) 664 | * class PeopleComponent { 665 | * constructor(http: Http) { 666 | * http.get('people.json') 667 | * //Get the RxJS Subject 668 | * .toRx() 669 | * // Call map on the response observable to get the parsed people object 670 | * .map(res => res.json()) 671 | * // Subscribe to the observable to get the parsed people object and attach it to the 672 | * // component 673 | * .subscribe(people => this.people = people); 674 | * } 675 | * } 676 | * ``` 677 | * 678 | * To use the {@link EventEmitter} returned by `Http`, simply pass a generator (See "interface 679 | * Generator" in the Async Generator spec: https://github.com/jhusain/asyncgenerator) to the 680 | * `observer` method of the returned emitter, with optional methods of `next`, `throw`, and `return`. 681 | * 682 | * #Example 683 | * 684 | * ``` 685 | * http.get('people.json').observer({next: (value) => this.people = people}); 686 | * ``` 687 | * 688 | * The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" ( 689 | * {@link XHRBackend} in this case), which could be mocked with dependency injection by replacing 690 | * the {@link XHRBackend} binding, as in the following example: 691 | * 692 | * #Example 693 | * 694 | * ``` 695 | * import {MockBackend, BaseRequestOptions, Http} from 'angular2/http'; 696 | * var injector = Injector.resolveAndCreate([ 697 | * BaseRequestOptions, 698 | * MockBackend, 699 | * bind(Http).toFactory( 700 | * function(backend, defaultOptions) { 701 | * return new Http(backend, defaultOptions); 702 | * }, 703 | * [MockBackend, BaseRequestOptions]) 704 | * ]); 705 | * var http = injector.get(Http); 706 | * http.get('request-from-mock-backend.json').toRx().subscribe((res:Response) => doSomething(res)); 707 | * ``` 708 | */ 709 | class Http { 710 | 711 | 712 | /** 713 | * Performs any type of http request. First argument is required, and can either be a url or 714 | * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} 715 | * object can be provided as the 2nd argument. The options object will be merged with the values 716 | * of {@link BaseRequestOptions} before performing the request. 717 | */ 718 | request(url: string | Request, options?: RequestOptionsArgs): ng.EventEmitter; 719 | 720 | 721 | /** 722 | * Performs a request with `get` http method. 723 | */ 724 | get(url: string, options?: RequestOptionsArgs): ng.EventEmitter; 725 | 726 | 727 | /** 728 | * Performs a request with `post` http method. 729 | */ 730 | post(url: string, body: string, options?: RequestOptionsArgs): ng.EventEmitter; 731 | 732 | 733 | /** 734 | * Performs a request with `put` http method. 735 | */ 736 | put(url: string, body: string, options?: RequestOptionsArgs): ng.EventEmitter; 737 | 738 | 739 | /** 740 | * Performs a request with `delete` http method. 741 | */ 742 | delete(url: string, options?: RequestOptionsArgs): ng.EventEmitter; 743 | 744 | 745 | /** 746 | * Performs a request with `patch` http method. 747 | */ 748 | patch(url: string, body: string, options?: RequestOptionsArgs): ng.EventEmitter; 749 | 750 | 751 | /** 752 | * Performs a request with `head` http method. 753 | */ 754 | head(url: string, options?: RequestOptionsArgs): ng.EventEmitter; 755 | } 756 | 757 | class Jsonp extends Http { 758 | 759 | 760 | /** 761 | * Performs any type of http request. First argument is required, and can either be a url or 762 | * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} 763 | * object can be provided as the 2nd argument. The options object will be merged with the values 764 | * of {@link BaseRequestOptions} before performing the request. 765 | */ 766 | request(url: string | Request, options?: RequestOptionsArgs): ng.EventEmitter; 767 | } 768 | 769 | 770 | /** 771 | * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as 772 | * specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class). The only known 773 | * difference from the spec is the lack of an `entries` method. 774 | */ 775 | class Headers { 776 | 777 | 778 | /** 779 | * Appends a header to existing list of header values for a given header name. 780 | */ 781 | append(name: string, value: string): void; 782 | 783 | 784 | /** 785 | * Deletes all header values for the given name. 786 | */ 787 | delete(name: string): void; 788 | 789 | forEach(fn: Function): void; 790 | 791 | 792 | /** 793 | * Returns first header that matches given name. 794 | */ 795 | get(header: string): string; 796 | 797 | 798 | /** 799 | * Check for existence of header by given name. 800 | */ 801 | has(header: string): boolean; 802 | 803 | 804 | /** 805 | * Provides names of set headers 806 | */ 807 | keys(): string[]; 808 | 809 | 810 | /** 811 | * Sets or overrides header value for given name. 812 | */ 813 | set(header: string, value: string | string[]): void; 814 | 815 | 816 | /** 817 | * Returns values of all headers. 818 | */ 819 | values(): string[][]; 820 | 821 | 822 | /** 823 | * Returns list of header values for a given name. 824 | */ 825 | getAll(header: string): string[]; 826 | 827 | 828 | /** 829 | * This method is not implemented. 830 | */ 831 | entries(): void; 832 | } 833 | 834 | 835 | /** 836 | * Acceptable response types to be associated with a {@link Response}, based on 837 | * [ResponseType](https://fetch.spec.whatwg.org/#responsetype) from the Fetch spec. 838 | */ 839 | enum ResponseTypes { 840 | 841 | Basic, 842 | 843 | Cors, 844 | 845 | Default, 846 | 847 | Error, 848 | 849 | Opaque 850 | } 851 | 852 | 853 | /** 854 | * All possible states in which a connection can be, based on 855 | * [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an 856 | * additional "CANCELLED" state. 857 | */ 858 | enum ReadyStates { 859 | 860 | Unsent, 861 | 862 | Open, 863 | 864 | HeadersReceived, 865 | 866 | Loading, 867 | 868 | Done, 869 | 870 | Cancelled 871 | } 872 | 873 | 874 | /** 875 | * Supported http methods. 876 | */ 877 | enum RequestMethods { 878 | 879 | Get, 880 | 881 | Post, 882 | 883 | Put, 884 | 885 | Delete, 886 | 887 | Options, 888 | 889 | Head, 890 | 891 | Patch 892 | } 893 | 894 | 895 | /** 896 | * Acceptable credentials option to be associated with a {@link Request}, based on 897 | * [RequestCredentials](https://fetch.spec.whatwg.org/#requestcredentials) from the Fetch spec. 898 | */ 899 | enum RequestCredentialsOpts { 900 | 901 | Omit, 902 | 903 | SameOrigin, 904 | 905 | Include 906 | } 907 | 908 | 909 | /** 910 | * Acceptable cache option to be associated with a {@link Request}, based on 911 | * [RequestCache](https://fetch.spec.whatwg.org/#requestcache) from the Fetch spec. 912 | */ 913 | enum RequestCacheOpts { 914 | 915 | Default, 916 | 917 | NoStore, 918 | 919 | Reload, 920 | 921 | NoCache, 922 | 923 | ForceCache, 924 | 925 | OnlyIfCached 926 | } 927 | 928 | 929 | /** 930 | * Acceptable origin modes to be associated with a {@link Request}, based on 931 | * [RequestMode](https://fetch.spec.whatwg.org/#requestmode) from the Fetch spec. 932 | */ 933 | enum RequestModesOpts { 934 | 935 | Cors, 936 | 937 | NoCors, 938 | 939 | SameOrigin 940 | } 941 | 942 | 943 | /** 944 | * Map-like representation of url search parameters, based on 945 | * [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard, 946 | * with several extensions for merging URLSearchParams objects: 947 | * - setAll() 948 | * - appendAll() 949 | * - replaceAll() 950 | */ 951 | class URLSearchParams { 952 | 953 | paramsMap: Map; 954 | 955 | rawParams: string; 956 | 957 | clone(): URLSearchParams; 958 | 959 | has(param: string): boolean; 960 | 961 | get(param: string): string; 962 | 963 | getAll(param: string): string[]; 964 | 965 | set(param: string, val: string): void; 966 | 967 | setAll(searchParams: URLSearchParams): void; 968 | 969 | append(param: string, val: string): void; 970 | 971 | appendAll(searchParams: URLSearchParams): void; 972 | 973 | replaceAll(searchParams: URLSearchParams): void; 974 | 975 | toString(): string; 976 | 977 | delete(param: string): void; 978 | } 979 | 980 | 981 | /** 982 | * Provides a basic set of injectables to use the {@link Http} service in any application. 983 | * 984 | * #Example 985 | * 986 | * ``` 987 | * import {HTTP_BINDINGS, Http} from 'http/http'; 988 | * @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]}) 989 | * @View({template: '{{data}}'}) 990 | * class MyApp { 991 | * constructor(http:Http) { 992 | * http.request('data.txt').subscribe(res => this.data = res.text()); 993 | * } 994 | * } 995 | * ``` 996 | */ 997 | const HTTP_BINDINGS : any[] ; 998 | 999 | const JSONP_BINDINGS : any[] ; 1000 | 1001 | } 1002 | 1003 | declare module "angular2/http" { 1004 | export = ngHttp; 1005 | } 1006 | -------------------------------------------------------------------------------- /typings/rx/rx-lite.d.ts: -------------------------------------------------------------------------------- 1 | // DefinitelyTyped: partial 2 | 3 | // This file contains common part of defintions for rx.d.ts and rx.lite.d.ts 4 | // Do not include the file separately. 5 | 6 | declare module Rx { 7 | export module internals { 8 | function isEqual(left: any, right: any): boolean; 9 | function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable; 10 | 11 | // Priority Queue for Scheduling 12 | export class PriorityQueue { 13 | constructor(capacity: number); 14 | 15 | length: number; 16 | 17 | isHigherPriority(left: number, right: number): boolean; 18 | percolate(index: number): void; 19 | heapify(index: number): void; 20 | peek(): ScheduledItem; 21 | removeAt(index: number): void; 22 | dequeue(): ScheduledItem; 23 | enqueue(item: ScheduledItem): void; 24 | remove(item: ScheduledItem): boolean; 25 | 26 | static count: number; 27 | } 28 | 29 | export class ScheduledItem { 30 | constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number); 31 | 32 | scheduler: IScheduler; 33 | state: TTime; 34 | action: (scheduler: IScheduler, state: any) => IDisposable; 35 | dueTime: TTime; 36 | comparer: (x: TTime, y: TTime) => number; 37 | disposable: SingleAssignmentDisposable; 38 | 39 | invoke(): void; 40 | compareTo(other: ScheduledItem): number; 41 | isCancelled(): boolean; 42 | invokeCore(): IDisposable; 43 | } 44 | } 45 | 46 | export module config { 47 | export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; 48 | } 49 | 50 | export module helpers { 51 | function noop(): void; 52 | function notDefined(value: any): boolean; 53 | function identity(value: T): T; 54 | function defaultNow(): number; 55 | function defaultComparer(left: any, right: any): boolean; 56 | function defaultSubComparer(left: any, right: any): number; 57 | function defaultKeySerializer(key: any): string; 58 | function defaultError(err: any): void; 59 | function isPromise(p: any): boolean; 60 | function asArray(...args: T[]): T[]; 61 | function not(value: any): boolean; 62 | function isFunction(value: any): boolean; 63 | } 64 | 65 | export interface IDisposable { 66 | dispose(): void; 67 | } 68 | 69 | export class CompositeDisposable implements IDisposable { 70 | constructor (...disposables: IDisposable[]); 71 | constructor (disposables: IDisposable[]); 72 | 73 | isDisposed: boolean; 74 | length: number; 75 | 76 | dispose(): void; 77 | add(item: IDisposable): void; 78 | remove(item: IDisposable): boolean; 79 | toArray(): IDisposable[]; 80 | } 81 | 82 | export class Disposable implements IDisposable { 83 | constructor(action: () => void); 84 | 85 | static create(action: () => void): IDisposable; 86 | static empty: IDisposable; 87 | 88 | dispose(): void; 89 | } 90 | 91 | // Single assignment 92 | export class SingleAssignmentDisposable implements IDisposable { 93 | constructor(); 94 | 95 | isDisposed: boolean; 96 | current: IDisposable; 97 | 98 | dispose(): void ; 99 | getDisposable(): IDisposable; 100 | setDisposable(value: IDisposable): void ; 101 | } 102 | 103 | // SerialDisposable it's an alias of SingleAssignmentDisposable 104 | export class SerialDisposable extends SingleAssignmentDisposable { 105 | constructor(); 106 | } 107 | 108 | export class RefCountDisposable implements IDisposable { 109 | constructor(disposable: IDisposable); 110 | 111 | dispose(): void; 112 | 113 | isDisposed: boolean; 114 | getDisposable(): IDisposable; 115 | } 116 | 117 | export interface IScheduler { 118 | now(): number; 119 | isScheduler(value: any): boolean; 120 | 121 | schedule(action: () => void): IDisposable; 122 | scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; 123 | scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable; 124 | scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; 125 | scheduleWithRelative(dueTime: number, action: () => void): IDisposable; 126 | scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; 127 | 128 | scheduleRecursive(action: (action: () =>void ) =>void ): IDisposable; 129 | scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) =>void ) =>void ): IDisposable; 130 | scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; 131 | scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; 132 | scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) =>void ) =>void ): IDisposable; 133 | scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) =>void ) =>void ): IDisposable; 134 | 135 | schedulePeriodic(period: number, action: () => void): IDisposable; 136 | schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable; 137 | } 138 | 139 | export interface Scheduler extends IScheduler { 140 | } 141 | 142 | export interface SchedulerStatic { 143 | new ( 144 | now: () => number, 145 | schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, 146 | scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, 147 | scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler; 148 | 149 | normalize(timeSpan: number): number; 150 | 151 | immediate: IScheduler; 152 | currentThread: ICurrentThreadScheduler; 153 | default: IScheduler; // alias for Scheduler.timeout 154 | timeout: IScheduler; 155 | } 156 | 157 | export var Scheduler: SchedulerStatic; 158 | 159 | // Current Thread IScheduler 160 | interface ICurrentThreadScheduler extends IScheduler { 161 | scheduleRequired(): boolean; 162 | } 163 | 164 | // Notifications 165 | export class Notification { 166 | accept(observer: IObserver): void; 167 | accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; 168 | toObservable(scheduler?: IScheduler): Observable; 169 | hasValue: boolean; 170 | equals(other: Notification): boolean; 171 | kind: string; 172 | value: T; 173 | exception: any; 174 | 175 | static createOnNext(value: T): Notification; 176 | static createOnError(exception: any): Notification; 177 | static createOnCompleted(): Notification; 178 | } 179 | 180 | /** 181 | * Promise A+ 182 | */ 183 | export interface IPromise { 184 | then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; 185 | then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; 186 | then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; 187 | then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; 188 | } 189 | 190 | // Observer 191 | export interface IObserver { 192 | onNext(value: T): void; 193 | onError(exception: any): void; 194 | onCompleted(): void; 195 | } 196 | 197 | export interface Observer extends IObserver { 198 | toNotifier(): (notification: Notification) => void; 199 | asObserver(): Observer; 200 | } 201 | 202 | interface ObserverStatic { 203 | create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; 204 | fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer; 205 | } 206 | 207 | export var Observer: ObserverStatic; 208 | 209 | export interface IObservable { 210 | subscribe(observer: Observer): IDisposable; 211 | subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; 212 | 213 | subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable; 214 | subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable; 215 | subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable; 216 | } 217 | 218 | export interface Observable extends IObservable { 219 | forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe 220 | toArray(): Observable; 221 | 222 | catch(handler: (exception: any) => Observable): Observable; 223 | catchException(handler: (exception: any) => Observable): Observable; // alias for catch 224 | catch(handler: (exception: any) => IPromise): Observable; 225 | catchException(handler: (exception: any) => IPromise): Observable; // alias for catch 226 | catch(second: Observable): Observable; 227 | catchException(second: Observable): Observable; // alias for catch 228 | combineLatest(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 229 | combineLatest(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 230 | combineLatest(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 231 | combineLatest(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 232 | combineLatest(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 233 | combineLatest(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 234 | combineLatest(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 235 | combineLatest(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 236 | combineLatest(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 237 | combineLatest(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 238 | combineLatest(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 239 | combineLatest(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 240 | combineLatest(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 241 | combineLatest(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 242 | combineLatest(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; 243 | combineLatest(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; 244 | combineLatest(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; 245 | withLatestFrom(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 246 | withLatestFrom(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 247 | withLatestFrom(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 248 | withLatestFrom(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 249 | withLatestFrom(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 250 | withLatestFrom(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 251 | withLatestFrom(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 252 | withLatestFrom(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 253 | withLatestFrom(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 254 | withLatestFrom(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 255 | withLatestFrom(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 256 | withLatestFrom(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 257 | withLatestFrom(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 258 | withLatestFrom(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 259 | withLatestFrom(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; 260 | withLatestFrom(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; 261 | withLatestFrom(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; 262 | concat(...sources: Observable[]): Observable; 263 | concat(...sources: IPromise[]): Observable; 264 | concat(sources: Observable[]): Observable; 265 | concat(sources: IPromise[]): Observable; 266 | concatAll(): T; 267 | concatObservable(): T; // alias for concatAll 268 | concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat 269 | concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat 270 | concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat 271 | concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat 272 | concatMap(sequence: Observable): Observable; // alias for selectConcat 273 | merge(maxConcurrent: number): T; 274 | merge(other: Observable): Observable; 275 | merge(other: IPromise): Observable; 276 | mergeAll(): T; 277 | mergeObservable(): T; // alias for mergeAll 278 | skipUntil(other: Observable): Observable; 279 | skipUntil(other: IPromise): Observable; 280 | switch(): T; 281 | switchLatest(): T; // alias for switch 282 | takeUntil(other: Observable): Observable; 283 | takeUntil(other: IPromise): Observable; 284 | zip(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 285 | zip(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 286 | zip(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 287 | zip(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 288 | zip(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 289 | zip(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 290 | zip(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 291 | zip(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 292 | zip(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 293 | zip(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 294 | zip(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 295 | zip(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 296 | zip(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 297 | zip(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 298 | zip(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; 299 | zip(second: Observable[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; 300 | zip(second: IPromise[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; 301 | 302 | asObservable(): Observable; 303 | dematerialize(): Observable; 304 | distinctUntilChanged(skipParameter: boolean, comparer: (x: T, y: T) => boolean): Observable; 305 | distinctUntilChanged(keySelector?: (value: T) => TValue, comparer?: (x: TValue, y: TValue) => boolean): Observable; 306 | do(observer: Observer): Observable; 307 | doAction(observer: Observer): Observable; // alias for do 308 | tap(observer: Observer): Observable; // alias for do 309 | do(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; 310 | doAction(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do 311 | tap(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do 312 | 313 | doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; 314 | doOnError(onError: (exception: any) => void, thisArg?: any): Observable; 315 | doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; 316 | tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable; 317 | tapOnError(onError: (exception: any) => void, thisArg?: any): Observable; 318 | tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable; 319 | 320 | finally(action: () => void): Observable; 321 | finallyAction(action: () => void): Observable; // alias for finally 322 | ignoreElements(): Observable; 323 | materialize(): Observable>; 324 | repeat(repeatCount?: number): Observable; 325 | retry(retryCount?: number): Observable; 326 | scan(accumulator: (acc: TAcc, value: T, seed: TAcc) => TAcc): Observable; 327 | scan(accumulator: (acc: T, value: T) => T): Observable; 328 | skipLast(count: number): Observable; 329 | startWith(...values: T[]): Observable; 330 | startWith(scheduler: IScheduler, ...values: T[]): Observable; 331 | takeLast(count: number): Observable; 332 | takeLastBuffer(count: number): Observable; 333 | 334 | select(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; 335 | map(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for select 336 | pluck(prop: string): Observable; 337 | selectMany(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; 338 | selectMany(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; 339 | selectMany(selector: (value: T) => Observable): Observable; 340 | selectMany(selector: (value: T) => IPromise): Observable; 341 | selectMany(other: Observable): Observable; 342 | selectMany(other: IPromise): Observable; 343 | selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany 344 | flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany 345 | flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany 346 | flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany 347 | flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany 348 | flatMap(other: Observable): Observable; // alias for selectMany 349 | flatMap(other: IPromise): Observable; // alias for selectMany 350 | flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany 351 | 352 | /** 353 | * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. 354 | * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. 355 | * @param {Function} onError A transform function to apply when an error occurs in the source sequence. 356 | * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. 357 | * @param {Any} [thisArg] An optional "this" to use to invoke each transform. 358 | * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. 359 | */ 360 | selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; 361 | 362 | /** 363 | * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. 364 | * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. 365 | * @param {Function} onError A transform function to apply when an error occurs in the source sequence. 366 | * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. 367 | * @param {Any} [thisArg] An optional "this" to use to invoke each transform. 368 | * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. 369 | */ 370 | flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; 371 | 372 | selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; 373 | selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; 374 | selectConcat(selector: (value: T, index: number) => Observable): Observable; 375 | selectConcat(selector: (value: T, index: number) => IPromise): Observable; 376 | selectConcat(sequence: Observable): Observable; 377 | 378 | /** 379 | * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then 380 | * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. 381 | * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. 382 | * @param [thisArg] Object to use as this when executing callback. 383 | * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences 384 | * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. 385 | */ 386 | selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; 387 | /** 388 | * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then 389 | * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. 390 | * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. 391 | * @param [thisArg] Object to use as this when executing callback. 392 | * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences 393 | * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. 394 | */ 395 | flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch 396 | /** 397 | * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then 398 | * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. 399 | * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. 400 | * @param [thisArg] Object to use as this when executing callback. 401 | * @since 2.2.28 402 | * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences 403 | * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. 404 | */ 405 | switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch 406 | 407 | skip(count: number): Observable; 408 | skipWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; 409 | take(count: number, scheduler?: IScheduler): Observable; 410 | takeWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; 411 | where(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; 412 | filter(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for where 413 | 414 | /** 415 | * Converts an existing observable sequence to an ES6 Compatible Promise 416 | * @example 417 | * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); 418 | * @param promiseCtor The constructor of the promise. 419 | * @returns An ES6 compatible promise with the last value from the observable sequence. 420 | */ 421 | toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; 422 | /** 423 | * Converts an existing observable sequence to an ES6 Compatible Promise 424 | * @example 425 | * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); 426 | * 427 | * // With config 428 | * Rx.config.Promise = RSVP.Promise; 429 | * var promise = Rx.Observable.return(42).toPromise(); 430 | * @param [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. 431 | * @returns An ES6 compatible promise with the last value from the observable sequence. 432 | */ 433 | toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }): IPromise; 434 | 435 | // Experimental Flattening 436 | 437 | /** 438 | * Performs a exclusive waiting for the first to finish before subscribing to another observable. 439 | * Observables that come in between subscriptions will be dropped on the floor. 440 | * Can be applied on `Observable>` or `Observable>`. 441 | * @since 2.2.28 442 | * @returns A exclusive observable with only the results that happen when subscribed. 443 | */ 444 | exclusive(): Observable; 445 | 446 | /** 447 | * Performs a exclusive map waiting for the first to finish before subscribing to another observable. 448 | * Observables that come in between subscriptions will be dropped on the floor. 449 | * Can be applied on `Observable>` or `Observable>`. 450 | * @since 2.2.28 451 | * @param selector Selector to invoke for every item in the current subscription. 452 | * @param [thisArg] An optional context to invoke with the selector parameter. 453 | * @returns {An exclusive observable with only the results that happen when subscribed. 454 | */ 455 | exclusiveMap(selector: (value: I, index: number, source: Observable) => R, thisArg?: any): Observable; 456 | } 457 | 458 | interface ObservableStatic { 459 | create(subscribe: (observer: Observer) => IDisposable): Observable; 460 | create(subscribe: (observer: Observer) => () => void): Observable; 461 | create(subscribe: (observer: Observer) => void): Observable; 462 | createWithDisposable(subscribe: (observer: Observer) => IDisposable): Observable; 463 | defer(observableFactory: () => Observable): Observable; 464 | defer(observableFactory: () => IPromise): Observable; 465 | empty(scheduler?: IScheduler): Observable; 466 | 467 | /** 468 | * This method creates a new Observable sequence from an array object. 469 | * @param array An array-like or iterable object to convert to an Observable sequence. 470 | * @param mapFn Map function to call on every element of the array. 471 | * @param [thisArg] The context to use calling the mapFn if provided. 472 | * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. 473 | */ 474 | from(array: T[], mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; 475 | /** 476 | * This method creates a new Observable sequence from an array object. 477 | * @param array An array-like or iterable object to convert to an Observable sequence. 478 | * @param [mapFn] Map function to call on every element of the array. 479 | * @param [thisArg] The context to use calling the mapFn if provided. 480 | * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. 481 | */ 482 | from(array: T[], mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; 483 | 484 | /** 485 | * This method creates a new Observable sequence from an array-like object. 486 | * @param array An array-like or iterable object to convert to an Observable sequence. 487 | * @param mapFn Map function to call on every element of the array. 488 | * @param [thisArg] The context to use calling the mapFn if provided. 489 | * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. 490 | */ 491 | from(array: { length: number;[index: number]: T; }, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; 492 | /** 493 | * This method creates a new Observable sequence from an array-like object. 494 | * @param array An array-like or iterable object to convert to an Observable sequence. 495 | * @param [mapFn] Map function to call on every element of the array. 496 | * @param [thisArg] The context to use calling the mapFn if provided. 497 | * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. 498 | */ 499 | from(array: { length: number;[index: number]: T; }, mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; 500 | 501 | /** 502 | * This method creates a new Observable sequence from an array-like or iterable object. 503 | * @param array An array-like or iterable object to convert to an Observable sequence. 504 | * @param [mapFn] Map function to call on every element of the array. 505 | * @param [thisArg] The context to use calling the mapFn if provided. 506 | * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. 507 | */ 508 | from(iterable: any, mapFn?: (value: any, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; 509 | 510 | fromArray(array: T[], scheduler?: IScheduler): Observable; 511 | fromArray(array: { length: number;[index: number]: T; }, scheduler?: IScheduler): Observable; 512 | 513 | generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; 514 | never(): Observable; 515 | 516 | /** 517 | * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. 518 | * 519 | * @example 520 | * var res = Rx.Observable.of(1, 2, 3); 521 | * @since 2.2.28 522 | * @returns The observable sequence whose elements are pulled from the given arguments. 523 | */ 524 | of(...values: T[]): Observable; 525 | 526 | /** 527 | * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. 528 | * @example 529 | * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); 530 | * @since 2.2.28 531 | * @param [scheduler] A scheduler to use for scheduling the arguments. 532 | * @returns The observable sequence whose elements are pulled from the given arguments. 533 | */ 534 | ofWithScheduler(scheduler?: IScheduler, ...values: T[]): Observable; 535 | range(start: number, count: number, scheduler?: IScheduler): Observable; 536 | repeat(value: T, repeatCount?: number, scheduler?: IScheduler): Observable; 537 | return(value: T, scheduler?: IScheduler): Observable; 538 | /** 539 | * @since 2.2.28 540 | */ 541 | just(value: T, scheduler?: IScheduler): Observable; // alias for return 542 | returnValue(value: T, scheduler?: IScheduler): Observable; // alias for return 543 | throw(exception: Error, scheduler?: IScheduler): Observable; 544 | throw(exception: any, scheduler?: IScheduler): Observable; 545 | throwException(exception: Error, scheduler?: IScheduler): Observable; // alias for throw 546 | throwException(exception: any, scheduler?: IScheduler): Observable; // alias for throw 547 | throwError(error: Error, scheduler?: IScheduler): Observable; // alias for throw 548 | throwError(error: any, scheduler?: IScheduler): Observable; // alias for throw 549 | 550 | catch(sources: Observable[]): Observable; 551 | catch(sources: IPromise[]): Observable; 552 | catchException(sources: Observable[]): Observable; // alias for catch 553 | catchException(sources: IPromise[]): Observable; // alias for catch 554 | catchError(sources: Observable[]): Observable; // alias for catch 555 | catchError(sources: IPromise[]): Observable; // alias for catch 556 | catch(...sources: Observable[]): Observable; 557 | catch(...sources: IPromise[]): Observable; 558 | catchException(...sources: Observable[]): Observable; // alias for catch 559 | catchException(...sources: IPromise[]): Observable; // alias for catch 560 | catchError(...sources: Observable[]): Observable; // alias for catch 561 | catchError(...sources: IPromise[]): Observable; // alias for catch 562 | 563 | combineLatest(first: Observable, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 564 | combineLatest(first: IPromise, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 565 | combineLatest(first: Observable, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 566 | combineLatest(first: IPromise, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 567 | combineLatest(first: Observable, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 568 | combineLatest(first: Observable, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 569 | combineLatest(first: Observable, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 570 | combineLatest(first: Observable, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 571 | combineLatest(first: IPromise, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 572 | combineLatest(first: IPromise, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 573 | combineLatest(first: IPromise, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 574 | combineLatest(first: IPromise, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 575 | combineLatest(first: Observable, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 576 | combineLatest(first: Observable, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 577 | combineLatest(first: Observable, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 578 | combineLatest(first: Observable, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 579 | combineLatest(first: Observable, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 580 | combineLatest(first: Observable, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 581 | combineLatest(first: Observable, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 582 | combineLatest(first: Observable, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 583 | combineLatest(first: IPromise, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 584 | combineLatest(first: IPromise, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 585 | combineLatest(first: IPromise, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 586 | combineLatest(first: IPromise, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 587 | combineLatest(first: IPromise, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 588 | combineLatest(first: IPromise, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 589 | combineLatest(first: IPromise, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 590 | combineLatest(first: IPromise, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 591 | combineLatest(first: Observable, second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; 592 | combineLatest(souces: Observable[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; 593 | combineLatest(souces: IPromise[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; 594 | 595 | withLatestFrom(first: Observable, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 596 | withLatestFrom(first: IPromise, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; 597 | withLatestFrom(first: Observable, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 598 | withLatestFrom(first: IPromise, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; 599 | withLatestFrom(first: Observable, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 600 | withLatestFrom(first: Observable, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 601 | withLatestFrom(first: Observable, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 602 | withLatestFrom(first: Observable, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 603 | withLatestFrom(first: IPromise, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 604 | withLatestFrom(first: IPromise, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 605 | withLatestFrom(first: IPromise, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 606 | withLatestFrom(first: IPromise, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; 607 | withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 608 | withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 609 | withLatestFrom(first: Observable, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 610 | withLatestFrom(first: Observable, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 611 | withLatestFrom(first: Observable, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 612 | withLatestFrom(first: Observable, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 613 | withLatestFrom(first: Observable, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 614 | withLatestFrom(first: Observable, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 615 | withLatestFrom(first: IPromise, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 616 | withLatestFrom(first: IPromise, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 617 | withLatestFrom(first: IPromise, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 618 | withLatestFrom(first: IPromise, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 619 | withLatestFrom(first: IPromise, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 620 | withLatestFrom(first: IPromise, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 621 | withLatestFrom(first: IPromise, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 622 | withLatestFrom(first: IPromise, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; 623 | withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; 624 | withLatestFrom(souces: Observable[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; 625 | withLatestFrom(souces: IPromise[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; 626 | 627 | concat(...sources: Observable[]): Observable; 628 | concat(...sources: IPromise[]): Observable; 629 | concat(sources: Observable[]): Observable; 630 | concat(sources: IPromise[]): Observable; 631 | merge(...sources: Observable[]): Observable; 632 | merge(...sources: IPromise[]): Observable; 633 | merge(sources: Observable[]): Observable; 634 | merge(sources: IPromise[]): Observable; 635 | merge(scheduler: IScheduler, ...sources: Observable[]): Observable; 636 | merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; 637 | merge(scheduler: IScheduler, sources: Observable[]): Observable; 638 | merge(scheduler: IScheduler, sources: IPromise[]): Observable; 639 | 640 | pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; 641 | 642 | zip(first: Observable, sources: Observable[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; 643 | zip(first: Observable, sources: IPromise[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; 644 | zip(source1: Observable, source2: Observable, resultSelector: (item1: T1, item2: T2) => TResult): Observable; 645 | zip(source1: Observable, source2: IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; 646 | zip(source1: Observable, source2: Observable, source3: Observable, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; 647 | zip(source1: Observable, source2: Observable, source3: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; 648 | zip(source1: Observable, source2: IPromise, source3: Observable, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; 649 | zip(source1: Observable, source2: IPromise, source3: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; 650 | zip(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 651 | zip(source1: Observable, source2: Observable, source3: Observable, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 652 | zip(source1: Observable, source2: Observable, source3: IPromise, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 653 | zip(source1: Observable, source2: Observable, source3: IPromise, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 654 | zip(source1: Observable, source2: IPromise, source3: Observable, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 655 | zip(source1: Observable, source2: IPromise, source3: Observable, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 656 | zip(source1: Observable, source2: IPromise, source3: IPromise, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 657 | zip(source1: Observable, source2: IPromise, source3: IPromise, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; 658 | zip(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; 659 | zipArray(...sources: Observable[]): Observable; 660 | zipArray(sources: Observable[]): Observable; 661 | 662 | /** 663 | * Converts a Promise to an Observable sequence 664 | * @param promise An ES6 Compliant promise. 665 | * @returns An Observable sequence which wraps the existing promise success and failure. 666 | */ 667 | fromPromise(promise: IPromise): Observable; 668 | 669 | prototype: any; 670 | } 671 | 672 | export var Observable: ObservableStatic; 673 | 674 | interface ISubject extends Observable, Observer, IDisposable { 675 | hasObservers(): boolean; 676 | } 677 | 678 | export interface Subject extends ISubject { 679 | } 680 | 681 | interface SubjectStatic { 682 | new (): Subject; 683 | create(observer?: Observer, observable?: Observable): ISubject; 684 | } 685 | 686 | export var Subject: SubjectStatic; 687 | 688 | export interface AsyncSubject extends Subject { 689 | } 690 | 691 | interface AsyncSubjectStatic { 692 | new (): AsyncSubject; 693 | } 694 | 695 | export var AsyncSubject: AsyncSubjectStatic; 696 | } 697 | --------------------------------------------------------------------------------