refactor(@angular-devkit/core): Type JobHandlerContext properly

The input field is not an unknown JsonValue, the type is part of the
generic. It's validated by the scheduler.
This commit is contained in:
Hans Larsen 2019-02-07 11:23:11 -08:00 committed by Alex Eagle
parent ca31640505
commit ef93ff8c78

View File

@ -39,7 +39,7 @@ export interface SimpleJobHandlerContext<
> extends JobHandlerContext<A, I, O> {
logger: LoggerApi;
createChannel: (name: string) => Observer<JsonValue>;
input: Observable<JsonValue>;
input: Observable<I>;
}
@ -68,7 +68,7 @@ export function createJobHandler<A extends JsonValue, I extends JsonValue, O ext
const handler = (argument: A, context: JobHandlerContext<A, I, O>) => {
const description = context.description;
const inboundBus = context.inboundBus;
const inputChannel = new Subject<JsonValue>();
const inputChannel = new Subject<I>();
let subscription: Subscription;
return new Observable<JobOutboundMessage<O>>(subject => {
@ -112,7 +112,7 @@ export function createJobHandler<A extends JsonValue, I extends JsonValue, O ext
const channels = new Map<string, Subject<JsonValue>>();
const newContext = {
const newContext: SimpleJobHandlerContext<A, I, O> = {
...context,
input: inputChannel.asObservable(),
logger,