From 0d721a087bf733f85c7f7d4b3763e1771ef35631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alb=C3=A9rico=20Dias=20Barreto=20Filho?= Date: Tue, 9 Jan 2024 14:00:05 -0300 Subject: [PATCH] fix: documentation --- README.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 6188757..2cd144d 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,11 @@ Custom hooks to help use overwolf api with the new react hooks technology. ## Install ```bash -npm install --save overwolf-hooks -pnpm install --save overwolf-hooks -yarn add overwolf-hooks +$ npm install --save overwolf-hooks +$ pnpm install --save overwolf-hooks +$ yarn add overwolf-hooks ``` -```` - ## How to use - If you are not familiar with Overwolf [overwolf api](https://overwolf.github.io/) @@ -46,37 +44,39 @@ return ( ) } - +``` ## Force Window update If you need to force update the window state, you can use the refreshState function. ```tsx -import { useWindow } from 'overwolf-hooks' +import { useWindow } from "overwolf-hooks"; const shouldDisplayLog = true; const shouldListenToWindowStateChanges = true; -const Panel = () => { - //listenToWindowStateChanges is set to true to listen to window state changes, so you can read the window state from the desktopWindowStateChanged variable -const [desktopWindow, desktopWindowStateChanged, refreshState] = useWindow("desktop", shouldDisplayLog, shouldListenToWindowStateChanges); - -useEffect(() => { - //........ any other code - //force update/rebind the window object - refreshState(); -}, [refreshState]); +const [desktopWindow, desktopWindowStateChanged, refreshState] = useWindow( + "desktop", + shouldDisplayLog, + shouldListenToWindowStateChanges +); -useEffect(() => { - //........ any other code - console.info("desktopWindowStateChanged", desktopWindowStateChanged); -}, [desktopWindowStateChanged]); +const Panel = () => { + useEffect(() => { + //........ any other code + //force update/rebind the window object + refreshState(); + }, [refreshState]); -return -} + useEffect(() => { + //........ any other code + console.info("desktopWindowStateChanged", desktopWindowStateChanged); + }, [desktopWindowStateChanged]); + return ; +}; ``` 2. **useDrag.tsx** @@ -112,10 +112,11 @@ return ( ```TSX const REQUIRED_FEATURES = ["game_info", "match_info", "game_events"]; -const RETRY_TIMES = 5; +const RETRY_TIMES = 10; const DISPLAY_OVERWOLF_HOOKS_LOGS = true; const BackgroundWindow = () => { + const [ingame] = useWindow("ingame", DISPLAY_OVERWOLF_HOOKS_LOGS); const { started, start, stop } = useGameEventProvider( { onInfoUpdates: (info) => { console.log("info", info); }, @@ -131,7 +132,9 @@ const BackgroundWindow = () => { return () => stop(); }, [start, stop]); + return null; } + ``` 4. **useRunningGame.tsx** @@ -158,5 +161,3 @@ return

Alert Window

## License MIT © [AlbericoD](https://github.com/AlbericoD) - -````