UNPKG

ngx-uploadx

Version:
74 lines (73 loc) 2.48 kB
import { OnDestroy } from '@angular/core'; import { Observable } from 'rxjs'; import { AjaxRequestConfig, AjaxResponse } from './ajax'; import { UploadState, UploadxControlEvent } from './interfaces'; import { UploadxFactoryOptions, UploadxOptions } from './options'; import { Uploader } from './uploader'; import * as i0 from "@angular/core"; export declare const UPLOAD_STATE_KEYS: (keyof UploadState)[]; export declare class UploadxService implements OnDestroy { /** Upload Queue */ queue: Uploader[]; readonly options: UploadxFactoryOptions; private readonly eventsStream; private subs; private ngZone; readonly ajax: import("./ajax").Ajax; private idService; constructor(); /** Upload status events */ get events(): Observable<UploadState>; /** * Initializes service * @param options global module options * @returns Observable that emits a new value on progress or status changes */ init(options?: UploadxOptions): Observable<UploadState>; /** * Initializes service * @param options global module options * @returns Observable that emits the current array of uploaders */ connect(options?: UploadxOptions): Observable<Uploader[]>; /** * Terminates all uploads and clears the queue */ disconnect(): void; /** * Returns current uploads state * @example * // restore background uploads * this.uploads = this.uploadService.state(); */ state(): UploadState[]; ngOnDestroy(): void; /** * Creates uploaders for files and adds them to the upload queue */ handleFiles(files: FileList | File | File[], options?: UploadxOptions): void; /** * Upload control * @example * // pause all * this.uploadService.control({ action: 'pause' }); * // pause upload with uploadId * this.uploadService.control({ action: 'pause', uploadId}); * // set token * this.uploadService.control({ token: `TOKEN` }); */ control(evt: UploadxControlEvent): void; /** * Number of active uploads */ get activeUploadsCount(): number; /** * Performs http requests */ request<T = string>(config: AjaxRequestConfig): Promise<AjaxResponse<T>>; private stateChange; private addUploaderInstance; private processQueue; static ɵfac: i0.ɵɵFactoryDeclaration<UploadxService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<UploadxService>; }