From 5755b458884d925a4b622da4861c3dc5bde9826f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 20 Dec 2020 19:35:35 +0100 Subject: [PATCH] browser tabs example introduced. --- src/component/main.vue | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/component/main.vue b/src/component/main.vue index 822c911b..03ceef8f 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -287,16 +287,14 @@ } // TODO: Refactor. - public browserNavigateUrl(url: string) { - this.websocket.send('browser/navigate/url', { url }) + public tabEvent(event: string, payload?: any | undefined) { + this.websocket.send('tabs/' + event, { payload }) } - public browserNavigateBack() { - this.websocket.send('browser/navigate/back') - } - - public browserNavigateForward() { - this.websocket.send('browser/navigate/forward') + // TODO: Refactor. + tabHander?: (event: string, payload: any) => any + public tabSubscribe(func: (event: string, payload: any) => any) { + this.tabHander = func } ///////////////////////////// @@ -325,6 +323,11 @@ } catch (e) {} break } + + // TODO: Refactor. + if (event.match(/^tabs\//) && this.tabHander) { + this.tabHander(event, payload.payload) + } }) this.websocket.on('connecting', () => { Vue.set(this.state.connection, 'websocket', 'connecting')