2020-10-09 19:35:46 +02:00
|
|
|
import { ViewHandle } from './utils/createViewHandle';
|
|
|
|
|
2021-01-12 01:33:10 +02:00
|
|
|
export interface EmitMessageEvent {
|
|
|
|
message: any;
|
|
|
|
}
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
export default class ViewController {
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
private handle_: ViewHandle;
|
|
|
|
private pluginId_: string;
|
|
|
|
private store_: any;
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2021-01-02 15:32:15 +02:00
|
|
|
public constructor(handle: ViewHandle, pluginId: string, store: any) {
|
2020-10-09 19:35:46 +02:00
|
|
|
this.handle_ = handle;
|
|
|
|
this.pluginId_ = pluginId;
|
|
|
|
this.store_ = store;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
protected get storeView(): any {
|
2021-01-02 15:32:15 +02:00
|
|
|
return this.store_.getState().pluginService.plugins[this.pluginId_].views[this.handle];
|
2020-10-09 19:35:46 +02:00
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
protected get store(): any {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.store_;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
public get pluginId(): string {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.pluginId_;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
public get key(): string {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.handle_;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
public get handle(): ViewHandle {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.handle_;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
public get type(): string {
|
2020-10-09 19:35:46 +02:00
|
|
|
throw new Error('Must be overriden');
|
|
|
|
}
|
|
|
|
|
2021-01-12 01:33:10 +02:00
|
|
|
public async emitMessage(event: EmitMessageEvent): Promise<any> {
|
2023-02-16 12:55:24 +02:00
|
|
|
console.warn('Calling ViewController.emitMessage - but not implemented', event);
|
2020-10-09 19:35:46 +02:00
|
|
|
}
|
|
|
|
|
2021-11-09 17:50:50 +02:00
|
|
|
public postMessage(message: any) {
|
2023-02-16 12:55:24 +02:00
|
|
|
console.warn('Calling ViewController.postMessage - but not implemented', message);
|
2021-11-09 17:50:50 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
}
|