UNPKG

2.33 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.dev/license
7 */
8import { JsonValue } from '@angular-devkit/core';
9import { Observable } from 'rxjs';
10import { JobDescription, JobHandler, JobName, Registry } from './api';
11/**
12 * SimpleJobRegistry job registration options.
13 */
14export interface RegisterJobOptions extends Partial<JobDescription> {
15}
16/**
17 * A simple job registry that keep a map of JobName => JobHandler internally.
18 */
19export declare class SimpleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
20 private _jobNames;
21 get<A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
22 /**
23 * Register a job handler. The name must be unique.
24 *
25 * @param name The name of the job.
26 * @param handler The function that will be called for the job.
27 * @param options An optional list of options to override the handler. {@see RegisterJobOptions}
28 */
29 register<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName, handler: JobHandler<A, I, O>, options?: RegisterJobOptions): void;
30 /**
31 * Register a job handler. The name must be unique.
32 *
33 * @param handler The function that will be called for the job.
34 * @param options An optional list of options to override the handler. {@see RegisterJobOptions}
35 */
36 register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(handler: JobHandler<ArgumentT, InputT, OutputT>, options?: RegisterJobOptions & {
37 name: string;
38 }): void;
39 protected _register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(name: JobName, handler: JobHandler<ArgumentT, InputT, OutputT>, options: RegisterJobOptions): void;
40 /**
41 * Returns the job names of all jobs.
42 */
43 getJobNames(): JobName[];
44}