forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.ts
More file actions
86 lines (78 loc) · 1.95 KB
/
Copy pathinterfaces.ts
File metadata and controls
86 lines (78 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/// <reference path="../../typings/rx/rx.all.d.ts" />
import {
ReadyStates,
RequestModesOpts,
RequestMethods,
RequestCacheOpts,
RequestCredentialsOpts,
ResponseTypes
} from './enums';
import {Headers} from './headers';
import {URLSearchParams} from './url_search_params';
export interface IRequestOptions {
method?: RequestMethods;
headers?: Headers;
body?: URLSearchParams | FormData | Blob | string;
mode?: RequestModesOpts;
credentials?: RequestCredentialsOpts;
cache?: RequestCacheOpts;
}
export interface IRequest {
method: RequestMethods;
mode: RequestModesOpts;
credentials: RequestCredentialsOpts;
}
export interface ResponseOptions {
status?: number;
statusText?: string;
headers?: Headers | Object;
type?: ResponseTypes;
url?: string;
}
export interface IResponse {
headers: Headers;
ok: boolean;
status: number;
statusText: string;
type: ResponseTypes;
url: string;
totalBytes: number;
bytesLoaded: number;
blob(): Blob;
arrayBuffer(): ArrayBuffer;
text(): string;
json(): Object;
}
export interface ConnectionBackend {
createConnection(observer: any, config: IRequest): Connection;
}
export interface Connection {
readyState: ReadyStates;
request: IRequest;
response: Rx.Subject<IResponse>;
dispose(): void;
}
/**
* Provides an interface to provide type information for {@link HttpFactory} when injecting.
*
* #Example
*
* ```
* * import {httpInjectables, HttpFactory, IHttp} from 'angular2/http';
* @Component({
* appInjector: [httpInjectables]
* })
* @View({
* templateUrl: 'people.html'
* })
* class MyComponent {
* constructor(@Inject(HttpFactory) http:IHttp) {
* http('people.json').subscribe(res => this.people = res.json());
* }
* }
* ```
*
*/
// Prefixed as IHttp because used in conjunction with Http class, but interface is callable
// constructor(@Inject(Http) http:IHttp)
export interface IHttp { (url: string, options?: IRequestOptions): Rx.Observable<IResponse> }