Skip to content

Commit 9335c2a

Browse files
Simplify ModelProcessor by extending A2UIModelProcessor
1 parent 7fd0763 commit 9335c2a

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

angular/projects/lib/src/lib/data/processor.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,19 @@ export interface DispatchedEvent {
2424
}
2525

2626
@Injectable({ providedIn: 'root' })
27-
export class ModelProcessor {
28-
private readonly processor = new v0_8.Data.A2UIModelProcessor();
27+
export class ModelProcessor extends v0_8.Data.A2UIModelProcessor {
2928
readonly events = new Subject<DispatchedEvent>();
3029

31-
getSurfaces() {
32-
return this.processor.getSurfaces();
33-
}
34-
35-
resolvePath(path: string, dataContextPath?: string) {
36-
return this.processor.resolvePath(path, dataContextPath);
37-
}
38-
39-
setData(
30+
override setData(
4031
node: v0_8.Types.AnyComponentNode,
4132
relativePath: string,
4233
value: v0_8.Types.DataValue,
4334
surfaceId?: v0_8.Types.SurfaceID | null
4435
) {
45-
return this.processor.setData(node, relativePath, value, surfaceId ?? undefined);
46-
}
47-
48-
getData(
49-
node: v0_8.Types.AnyComponentNode,
50-
relativePath: string,
51-
surfaceId?: string
52-
): v0_8.Types.DataValue | null {
53-
return this.processor.getData(node, relativePath, surfaceId);
54-
}
55-
56-
clearSurfaces() {
57-
this.processor.clearSurfaces();
58-
}
59-
60-
processMessages(messages: v0_8.Types.ServerToClientMessage[]) {
61-
this.processor.processMessages(messages);
36+
// Override setData to convert from optional inputs (which can be null)
37+
// to undefined so that this correctly falls back to the default value for
38+
// surfaceId.
39+
return super.setData(node, relativePath, value, surfaceId ?? undefined);
6240
}
6341

6442
dispatch(message: v0_8.Types.A2UIClientEventMessage): Promise<v0_8.Types.ServerToClientMessage[]> {

0 commit comments

Comments
 (0)