refactor(calls): refactor of call architecture

This commit is contained in:
Taso committed 2021-07-28 14:26:00 -04:00
1 parent 92b687b130
commit 36d1e993bd
21 files changed
+361 -185

No files matched your search

+15
View File
@@ -3,3 +3,18 @@ export const getSource = (): number => (global as any).source;
// Will clean string of any character that isn't 0-9, or a-z
export const clean = (input: string): string => (input ? input.replace(/[^0-9a-z]/gi, '') : input);
type onNetTypedCB<T> = (data: T) => void;
// Simple generic wrapper around onNet for type safety
export const onNetTyped = <T = any>(eventName: string, cb: onNetTypedCB<T>) => onNet(eventName, cb);
// Simple generic wrapper around emitNet, except that we switch src and first arg if on server.
// source is defined using the third arg
export const emitNetTyped = <T = any>(eventName: string, data: T, src?: number) => {
if (src) {
return emitNet(eventName, src, data);
}
emitNet(eventName, data);
};