source: trip-planner-front/node_modules/rxjs/internal/observable/dom/AjaxObservable.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.4 KB
Line 
1import { Observable } from '../../Observable';
2import { Subscriber } from '../../Subscriber';
3import { TeardownLogic } from '../../types';
4export interface AjaxRequest {
5 url?: string;
6 body?: any;
7 user?: string;
8 async?: boolean;
9 method?: string;
10 headers?: Object;
11 timeout?: number;
12 password?: string;
13 hasContent?: boolean;
14 crossDomain?: boolean;
15 withCredentials?: boolean;
16 createXHR?: () => XMLHttpRequest;
17 progressSubscriber?: Subscriber<any>;
18 responseType?: string;
19}
20export interface AjaxCreationMethod {
21 (urlOrRequest: string | AjaxRequest): Observable<AjaxResponse>;
22 get(url: string, headers?: Object): Observable<AjaxResponse>;
23 post(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
24 put(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
25 patch(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
26 delete(url: string, headers?: Object): Observable<AjaxResponse>;
27 getJSON<T>(url: string, headers?: Object): Observable<T>;
28}
29export declare function ajaxGet(url: string, headers?: Object): AjaxObservable<AjaxResponse>;
30export declare function ajaxPost(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
31export declare function ajaxDelete(url: string, headers?: Object): Observable<AjaxResponse>;
32export declare function ajaxPut(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
33export declare function ajaxPatch(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
34export declare function ajaxGetJSON<T>(url: string, headers?: Object): Observable<T>;
35/**
36 * We need this JSDoc comment for affecting ESDoc.
37 * @extends {Ignored}
38 * @hide true
39 */
40export declare class AjaxObservable<T> extends Observable<T> {
41 /**
42 * Creates an observable for an Ajax request with either a request object with
43 * url, headers, etc or a string for a URL.
44 *
45 * ## Example
46 * ```ts
47 * import { ajax } from 'rxjs/ajax';
48 *
49 * const source1 = ajax('/products');
50 * const source2 = ajax({ url: 'products', method: 'GET' });
51 * ```
52 *
53 * @param {string|Object} request Can be one of the following:
54 * A string of the URL to make the Ajax call.
55 * An object with the following properties
56 * - url: URL of the request
57 * - body: The body of the request
58 * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE
59 * - async: Whether the request is async
60 * - headers: Optional headers
61 * - crossDomain: true if a cross domain request, else false
62 * - createXHR: a function to override if you need to use an alternate
63 * XMLHttpRequest implementation.
64 * - resultSelector: a function to use to alter the output value type of
65 * the Observable. Gets {@link AjaxResponse} as an argument.
66 * @return {Observable} An observable sequence containing the XMLHttpRequest.
67 * @static true
68 * @name ajax
69 * @owner Observable
70 * @nocollapse
71 */
72 static create: AjaxCreationMethod;
73 private request;
74 constructor(urlOrRequest: string | AjaxRequest);
75 /** @deprecated This is an internal implementation detail, do not use. */
76 _subscribe(subscriber: Subscriber<T>): TeardownLogic;
77}
78/**
79 * We need this JSDoc comment for affecting ESDoc.
80 * @ignore
81 * @extends {Ignored}
82 */
83export declare class AjaxSubscriber<T> extends Subscriber<Event> {
84 request: AjaxRequest;
85 private xhr;
86 private done;
87 constructor(destination: Subscriber<T>, request: AjaxRequest);
88 next(e: Event): void;
89 private send;
90 private serializeBody;
91 private setHeaders;
92 private getHeader;
93 private setupEvents;
94 unsubscribe(): void;
95}
96/**
97 * A normalized AJAX response.
98 *
99 * @see {@link ajax}
100 *
101 * @class AjaxResponse
102 */
103export declare class AjaxResponse {
104 originalEvent: Event;
105 xhr: XMLHttpRequest;
106 request: AjaxRequest;
107 /** @type {number} The HTTP status code */
108 status: number;
109 /** @type {string|ArrayBuffer|Document|object|any} The response data */
110 response: any;
111 /** @type {string} The raw responseText */
112 responseText: string;
113 /** @type {string} The responseType (e.g. 'json', 'arraybuffer', or 'xml') */
114 responseType: string;
115 constructor(originalEvent: Event, xhr: XMLHttpRequest, request: AjaxRequest);
116}
117export declare type AjaxErrorNames = 'AjaxError' | 'AjaxTimeoutError';
118/**
119 * A normalized AJAX error.
120 *
121 * @see {@link ajax}
122 *
123 * @class AjaxError
124 */
125export interface AjaxError extends Error {
126 /** @type {XMLHttpRequest} The XHR instance associated with the error */
127 xhr: XMLHttpRequest;
128 /** @type {AjaxRequest} The AjaxRequest associated with the error */
129 request: AjaxRequest;
130 /** @type {number} The HTTP status code */
131 status: number;
132 /** @type {string} The responseType (e.g. 'json', 'arraybuffer', or 'xml') */
133 responseType: string;
134 /** @type {string|ArrayBuffer|Document|object|any} The response data */
135 response: any;
136}
137export interface AjaxErrorCtor {
138 new (message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError;
139}
140export declare const AjaxError: AjaxErrorCtor;
141export interface AjaxTimeoutError extends AjaxError {
142}
143export interface AjaxTimeoutErrorCtor {
144 new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
145}
146/**
147 * @see {@link ajax}
148 *
149 * @class AjaxTimeoutError
150 */
151export declare const AjaxTimeoutError: AjaxTimeoutErrorCtor;
Note: See TracBrowser for help on using the repository browser.