mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-08 05:20:23 +00:00
style: code format
This commit is contained in:
parent
3f106810c7
commit
4b56ac44c2
3 changed files with 11 additions and 13 deletions
|
|
@ -17,11 +17,17 @@ type ShellEvent = {
|
||||||
args: string[];
|
args: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const createId = () => Math.floor(Math.random() * 9999) + 1;
|
const createId = () => Math.floor(Math.random() * 9999) + 1;
|
||||||
|
|
||||||
const useShell = () => {
|
const useShell = () => {
|
||||||
|
const on = (name: string, listener: (arg: any) => void) => {
|
||||||
|
events.on(name, listener);
|
||||||
|
};
|
||||||
|
|
||||||
|
const off = (name: string, listener: (arg: any) => void) => {
|
||||||
|
events.off(name, listener);
|
||||||
|
};
|
||||||
|
|
||||||
const send = (method: string, ...args: (string | number)[]) => {
|
const send = (method: string, ...args: (string | number)[]) => {
|
||||||
try {
|
try {
|
||||||
transport?.send(JSON.stringify({
|
transport?.send(JSON.stringify({
|
||||||
|
|
@ -31,19 +37,11 @@ const useShell = () => {
|
||||||
method: 'onEvent',
|
method: 'onEvent',
|
||||||
args: [method, ...args],
|
args: [method, ...args],
|
||||||
}));
|
}));
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error('Shell', 'Failed to send event', e);
|
console.error('Shell', 'Failed to send event', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const on = (name: string, listener: (arg: any) => void) => {
|
|
||||||
events.on(name, listener);
|
|
||||||
};
|
|
||||||
|
|
||||||
const off = (name: string, listener: (arg: any) => void) => {
|
|
||||||
events.off(name, listener);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!transport) return;
|
if (!transport) return;
|
||||||
|
|
||||||
|
|
|
||||||
2
src/types/global.d.ts
vendored
2
src/types/global.d.ts
vendored
|
|
@ -17,4 +17,4 @@ declare global {
|
||||||
var qt: Qt | undefined;
|
var qt: Qt | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {}
|
export {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue