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) - -````