my mistake lol

This commit is contained in:
chip committed 2020-11-11 14:33:48 +01:00
1 parent f7b8517155
commit 79c29c3f7e
4 files changed
+12 -15

No files matched your search

+4 -3
View File
@@ -1,3 +1,4 @@
import { useEffect, useRef } from "react";
import { eventNameFactory } from "../utils/nuiUtils";
@@ -7,7 +8,7 @@ interface IOptions {
once?: boolean;
}
export const useNuiEvent = (app, method, handler, options: IOptions = {}) => {
export const useNuiEvent = (app: any, method: any, handler: any, options: IOptions = {}) => {
const savedHandler: any = useRef();
const { capture, passive, once } = options;
@@ -17,7 +18,7 @@ export const useNuiEvent = (app, method, handler, options: IOptions = {}) => {
useEffect(() => {
const eventName = eventNameFactory(app, method);
const eventListener = (event) => {
const eventListener = (event: any ) => {
if (savedHandler.current && savedHandler.current.call) {
const { data } = event;
console.log(eventName, data);
@@ -28,4 +29,4 @@ export const useNuiEvent = (app, method, handler, options: IOptions = {}) => {
window.addEventListener(eventName, eventListener, opts);
return () => window.removeEventListener(eventName, eventListener, opts);
}, [app, method, capture, passive, once]);
};
};
@@ -9,7 +9,7 @@ interface IOptions {
export const useNuiService = (options: IOptions = {}) => {
const { capture, passive, once } = options;
const eventListener = (event) => {
const eventListener = (event: any) => {
const { app, method, data } = event.data;
if (app && method && data !== undefined) {
window.dispatchEvent(
@@ -24,4 +24,4 @@ export const useNuiService = (options: IOptions = {}) => {
window.addEventListener("message", eventListener, opts);
return () => window.removeEventListener("message", eventListener, opts);
}, [capture, passive, once]);
};
};
+4 -8
View File
@@ -1,17 +1,13 @@
// eslint-disable-next-line
export default {
async send(event, data = {}) {
// /// #if DEBUG
//return new Promise(resolve => setTimeout(resolve, 100));
// /// #endif
async send(event: any, data = {}) {
/* eslint-disable no-unreachable */
return fetch(`http://new-phone-who-dis/${event}`, {
return fetch(`http://or-ambumdt/${event}`, {
method: "post",
headers: {
"Content-type": "application/json; charset=UTF-8",
"Content-Type": "application/json; charset=UTF-8",
},
body: JSON.stringify(data),
});
/* eslint-enable no-unreachable */
},
};
+2 -2
View File
@@ -1,2 +1,2 @@
export const eventNameFactory = (app, method) => `${app}:${method}`;
export const eventNameMethod = (name) => name.split(":")[1] || null;
export const eventNameFactory = (app: any, method: any) => `${app}:${method}`;
export const eventNameMethod = (name: any) => name.split(":")[1] || null;