mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Add: Simcard, simcardService + Add: nuiEvent, nuiService
This commit is contained in:
1 parent
ec37fcde46
commit
f862100d4b
14 files changed
+101
-5
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { useEffect } from "react";
|
||||
import { eventNameFactory } from "../utils/nuiUtils";
|
||||
|
||||
export const useNuiService = (options = {}) => {
|
||||
const { capture, passive, once } = options;
|
||||
const eventListener = (event) => {
|
||||
console.log(event);
|
||||
const { app, method, data } = event.data;
|
||||
if (app && method && data) {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent(eventNameFactory(app, method), {
|
||||
data,
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
const opts = { capture, passive, once };
|
||||
window.addEventListener("message", eventListener, opts);
|
||||
return () => window.removeEventListener("message", eventListener, opts);
|
||||
}, [capture, passive, once]);
|
||||
};
|
||||
Reference in new issue
Block a user