From b532c7da20ffa866d79a62efdde700d8d7a830c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mal=C3=BD?= <michal.maly@ibt.cas.cz> Date: Mon, 10 Oct 2022 14:31:50 +0200 Subject: [PATCH] ReDNATCO plugin stage 22 --- src/apps/rednatco/api-impl.ts | 4 ++-- src/apps/rednatco/api.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/apps/rednatco/api-impl.ts b/src/apps/rednatco/api-impl.ts index b559ba13c..4a4dafce4 100644 --- a/src/apps/rednatco/api-impl.ts +++ b/src/apps/rednatco/api-impl.ts @@ -39,8 +39,8 @@ export class ReDNATCOMspApiImpl implements ReDNATCOMspApi.Object { this.target!.loadStructure(data, type); } - query(type: ReDNATCOMspApi.Queries.Type): ReDNATCOMspApi.Response { + query<T extends ReDNATCOMspApi.Queries.Type>(type: T): ReDNATCOMspApi.ResponseTypes[T] { this.check(); - return this.target!.apiQuery(type); + return this.target!.apiQuery(type) as ReDNATCOMspApi.ResponseTypes[T]; } } diff --git a/src/apps/rednatco/api.ts b/src/apps/rednatco/api.ts index b53d57801..8ccf9a541 100644 --- a/src/apps/rednatco/api.ts +++ b/src/apps/rednatco/api.ts @@ -106,6 +106,10 @@ export namespace ReDNATCOMspApi { } } export type Response = Queries.CurrentFilter|Queries.SelectedStep; + export type ResponseTypes = { + 'current-filter': Queries.CurrentFilter, + 'selected-step': Queries.SelectedStep, + } export interface Object { command: (cmd: Command) => void; @@ -113,6 +117,6 @@ export namespace ReDNATCOMspApi { init: (elemId: string, onEvent?: (evt: Event) => void) => void; isReady: () => boolean; loadStructure: (data: string, type: 'cif'|'pdb') => void; - query: (type: Queries.Type) => Response; + query: <T extends Queries.Type>(type: T) => ResponseTypes[T]; } } -- GitLab