UNPKG

8.44 kBTypeScriptView Raw
1export { Request } from './src/http/static_request';
2export { Response } from './src/http/static_response';
3export { RequestOptionsArgs, ResponseOptionsArgs, Connection, ConnectionBackend } from './src/http/interfaces';
4export { BrowserXhr } from './src/http/backends/browser_xhr';
5export { BaseRequestOptions, RequestOptions } from './src/http/base_request_options';
6export { BaseResponseOptions, ResponseOptions } from './src/http/base_response_options';
7export { XHRBackend, XHRConnection } from './src/http/backends/xhr_backend';
8export { JSONPBackend, JSONPConnection } from './src/http/backends/jsonp_backend';
9export { Http, Jsonp } from './src/http/http';
10export { Headers } from './src/http/headers';
11export { ResponseType, ReadyState, RequestMethod } from './src/http/enums';
12export { URLSearchParams } from './src/http/url_search_params';
13/**
14 * Provides a basic set of injectables to use the {@link Http} service in any application.
15 *
16 * The `HTTP_PROVIDERS` should be included either in a component's injector,
17 * or in the root injector when bootstrapping an application.
18 *
19 * ### Example ([live demo](http://plnkr.co/edit/snj7Nv?p=preview))
20 *
21 * ```
22 * import {Component} from 'angular2/core';
23 * import {bootstrap} from 'angular2/platform/browser';
24 * import {NgFor} from 'angular2/common';
25 * import {HTTP_PROVIDERS, Http} from 'angular2/http';
26 *
27 * @Component({
28 * selector: 'app',
29 * providers: [HTTP_PROVIDERS],
30 * template: `
31 * <div>
32 * <h1>People</h1>
33 * <ul>
34 * <li *ngFor="let person of people">
35 * {{person.name}}
36 * </li>
37 * </ul>
38 * </div>
39 * `,
40 * directives: [NgFor]
41 * })
42 * export class App {
43 * people: Object[];
44 * constructor(http:Http) {
45 * http.get('people.json').subscribe(res => {
46 * this.people = res.json();
47 * });
48 * }
49 * active:boolean = false;
50 * toggleActiveState() {
51 * this.active = !this.active;
52 * }
53 * }
54 *
55 * bootstrap(App)
56 * .catch(err => console.error(err));
57 * ```
58 *
59 * The primary public API included in `HTTP_PROVIDERS` is the {@link Http} class.
60 * However, other providers required by `Http` are included,
61 * which may be beneficial to override in certain cases.
62 *
63 * The providers included in `HTTP_PROVIDERS` include:
64 * * {@link Http}
65 * * {@link XHRBackend}
66 * * `BrowserXHR` - Private factory to create `XMLHttpRequest` instances
67 * * {@link RequestOptions} - Bound to {@link BaseRequestOptions} class
68 * * {@link ResponseOptions} - Bound to {@link BaseResponseOptions} class
69 *
70 * There may be cases where it makes sense to extend the base request options,
71 * such as to add a search string to be appended to all URLs.
72 * To accomplish this, a new provider for {@link RequestOptions} should
73 * be added in the same injector as `HTTP_PROVIDERS`.
74 *
75 * ### Example ([live demo](http://plnkr.co/edit/aCMEXi?p=preview))
76 *
77 * ```
78 * import {provide} from 'angular2/core';
79 * import {bootstrap} from 'angular2/platform/browser';
80 * import {HTTP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
81 *
82 * class MyOptions extends BaseRequestOptions {
83 * search: string = 'coreTeam=true';
84 * }
85 *
86 * bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
87 * .catch(err => console.error(err));
88 * ```
89 *
90 * Likewise, to use a mock backend for unit tests, the {@link XHRBackend}
91 * provider should be bound to {@link MockBackend}.
92 *
93 * ### Example ([live demo](http://plnkr.co/edit/7LWALD?p=preview))
94 *
95 * ```
96 * import {provide} from 'angular2/core';
97 * import {bootstrap} from 'angular2/platform/browser';
98 * import {HTTP_PROVIDERS, Http, Response, XHRBackend} from 'angular2/http';
99 * import {MockBackend} from 'angular2/http/testing';
100 *
101 * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
102 *
103 * var injector = Injector.resolveAndCreate([
104 * HTTP_PROVIDERS,
105 * MockBackend,
106 * provide(XHRBackend, {useExisting: MockBackend})
107 * ]);
108 * var http = injector.get(Http);
109 * var backend = injector.get(MockBackend);
110 *
111 * // Listen for any new requests
112 * backend.connections.observer({
113 * next: connection => {
114 * var response = new Response({body: people});
115 * setTimeout(() => {
116 * // Send a response to the request
117 * connection.mockRespond(response);
118 * });
119 * }
120 * });
121 *
122 * http.get('people.json').observer({
123 * next: res => {
124 * // Response came from mock backend
125 * console.log('first person', res.json()[0].name);
126 * }
127 * });
128 * ```
129 */
130export declare const HTTP_PROVIDERS: any[];
131/**
132 * See {@link HTTP_PROVIDERS} instead.
133 *
134 * @deprecated
135 */
136export declare const HTTP_BINDINGS: any[];
137/**
138 * Provides a basic set of providers to use the {@link Jsonp} service in any application.
139 *
140 * The `JSONP_PROVIDERS` should be included either in a component's injector,
141 * or in the root injector when bootstrapping an application.
142 *
143 * ### Example ([live demo](http://plnkr.co/edit/vmeN4F?p=preview))
144 *
145 * ```
146 * import {Component} from 'angular2/core';
147 * import {NgFor} from 'angular2/common';
148 * import {JSONP_PROVIDERS, Jsonp} from 'angular2/http';
149 *
150 * @Component({
151 * selector: 'app',
152 * providers: [JSONP_PROVIDERS],
153 * template: `
154 * <div>
155 * <h1>People</h1>
156 * <ul>
157 * <li *ngFor="let person of people">
158 * {{person.name}}
159 * </li>
160 * </ul>
161 * </div>
162 * `,
163 * directives: [NgFor]
164 * })
165 * export class App {
166 * people: Array<Object>;
167 * constructor(jsonp:Jsonp) {
168 * jsonp.request('people.json').subscribe(res => {
169 * this.people = res.json();
170 * })
171 * }
172 * }
173 * ```
174 *
175 * The primary public API included in `JSONP_PROVIDERS` is the {@link Jsonp} class.
176 * However, other providers required by `Jsonp` are included,
177 * which may be beneficial to override in certain cases.
178 *
179 * The providers included in `JSONP_PROVIDERS` include:
180 * * {@link Jsonp}
181 * * {@link JSONPBackend}
182 * * `BrowserJsonp` - Private factory
183 * * {@link RequestOptions} - Bound to {@link BaseRequestOptions} class
184 * * {@link ResponseOptions} - Bound to {@link BaseResponseOptions} class
185 *
186 * There may be cases where it makes sense to extend the base request options,
187 * such as to add a search string to be appended to all URLs.
188 * To accomplish this, a new provider for {@link RequestOptions} should
189 * be added in the same injector as `JSONP_PROVIDERS`.
190 *
191 * ### Example ([live demo](http://plnkr.co/edit/TFug7x?p=preview))
192 *
193 * ```
194 * import {provide} from 'angular2/core';
195 * import {bootstrap} from 'angular2/platform/browser';
196 * import {JSONP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
197 *
198 * class MyOptions extends BaseRequestOptions {
199 * search: string = 'coreTeam=true';
200 * }
201 *
202 * bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
203 * .catch(err => console.error(err));
204 * ```
205 *
206 * Likewise, to use a mock backend for unit tests, the {@link JSONPBackend}
207 * provider should be bound to {@link MockBackend}.
208 *
209 * ### Example ([live demo](http://plnkr.co/edit/HDqZWL?p=preview))
210 *
211 * ```
212 * import {provide, Injector} from 'angular2/core';
213 * import {JSONP_PROVIDERS, Jsonp, Response, JSONPBackend} from 'angular2/http';
214 * import {MockBackend} from 'angular2/http/testing';
215 *
216 * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
217 * var injector = Injector.resolveAndCreate([
218 * JSONP_PROVIDERS,
219 * MockBackend,
220 * provide(JSONPBackend, {useExisting: MockBackend})
221 * ]);
222 * var jsonp = injector.get(Jsonp);
223 * var backend = injector.get(MockBackend);
224 *
225 * // Listen for any new requests
226 * backend.connections.observer({
227 * next: connection => {
228 * var response = new Response({body: people});
229 * setTimeout(() => {
230 * // Send a response to the request
231 * connection.mockRespond(response);
232 * });
233 * }
234 * });
235
236 * jsonp.get('people.json').observer({
237 * next: res => {
238 * // Response came from mock backend
239 * console.log('first person', res.json()[0].name);
240 * }
241 * });
242 * ```
243 */
244export declare const JSONP_PROVIDERS: any[];
245/**
246 * See {@link JSONP_PROVIDERS} instead.
247 *
248 * @deprecated
249 */
250export declare const JSON_BINDINGS: any[];