replaced call socket() with apiOn/apiOff

This commit is contained in:
Jan Prochazka
2021-12-22 11:24:48 +01:00
parent 05ea435820
commit 2ace0bdb34
13 changed files with 41 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
import resolveApi, { resolveApiHeaders } from './resolveApi';
import { writable } from 'svelte/store';
import socket from './socket';
export async function apiCall(route: string, args: {} = undefined) {
const resp = await fetch(`${resolveApi()}/${route}`, {
@@ -14,9 +15,13 @@ export async function apiCall(route: string, args: {} = undefined) {
return resp.json();
}
export function apiOn(event: string, hander: Function) {}
export function apiOn(event: string, handler: Function) {
socket().on(event, handler);
}
export function apiOff(event: string, hander: Function) {}
export function apiOff(event: string, handler: Function) {
socket().off(event, handler);
}
import _ from 'lodash';