Skip to content

Commit 2c6c398

Browse files
clydinKeen Yee Liau
authored and
Keen Yee Liau
committed
refactor(@angular-devkit/core): allow promises for registry URI handlers
1 parent f52f043 commit 2c6c398

File tree

1 file changed

+3
-2
lines changed
  • packages/angular_devkit/core/src/json/schema

1 file changed

+3
-2
lines changed

packages/angular_devkit/core/src/json/schema/registry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ interface AjvRefMap {
4343
schema: JsonObject;
4444
}
4545

46-
export type UriHandler = (uri: string) => Observable<JsonObject> | null | undefined;
46+
export type UriHandler = (uri: string) =>
47+
Observable<JsonObject> | Promise<JsonObject> | null | undefined;
4748

4849
export class SchemaValidationException extends BaseException {
4950
public readonly errors: SchemaValidatorError[];
@@ -133,7 +134,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
133134
const handler = maybeHandler(uri);
134135
if (handler) {
135136
// The AJV API only understands Promises.
136-
return handler.pipe(
137+
return from(handler).pipe(
137138
tap(json => this._uriCache.set(uri, json)),
138139
).toPromise();
139140
}

0 commit comments

Comments
 (0)