import {UiVariableConsumer, UiVariableMap, UiVariableProvider} from "tc-shared/ui/utils/Variable"; class LocalUiVariableProvider extends UiVariableProvider { private consumer: LocalUiVariableConsumer; constructor() { super(); } destroy() { super.destroy(); this.consumer = undefined; } setConsumer(consumer: LocalUiVariableConsumer) { this.consumer = consumer; } protected doSendVariable(variable: string, customData: any, value: any) { this.consumer.notifyRemoteVariable(variable, customData, value); } public doEditVariable(variable: string, customData: any, newValue: any): Promise | void { return super.doEditVariable(variable, customData, newValue); } } class LocalUiVariableConsumer extends UiVariableConsumer { private provider: LocalUiVariableProvider; constructor(provider: LocalUiVariableProvider) { super(); this.provider = provider; } destroy() { super.destroy(); this.provider = undefined; } protected doEditVariable(variable: string, customData: any, value: any): Promise | void { return this.provider.doEditVariable(variable, customData, value); } protected doRequestVariable(variable: string, customData: any) { return this.provider.sendVariable(variable, customData); } public notifyRemoteVariable(variable: string, customData: any, value: any) { super.notifyRemoteVariable(variable, customData, value); } } export function createLocalUiVariables() : [UiVariableProvider, UiVariableConsumer] { const provider = new LocalUiVariableProvider(); const consumer = new LocalUiVariableConsumer(provider); provider.setConsumer(consumer); return [provider as any, consumer as any]; }