Skip to content

Commit

Permalink
fix: documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbericoD committed Jan 9, 2024
1 parent d0783d2 commit 0d721a0
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -46,37 +44,39 @@ return (
</div>
)
}
```

## 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 <CustomComponent {...desktopWindow}/>
}
useEffect(() => {
//........ any other code
console.info("desktopWindowStateChanged", desktopWindowStateChanged);
}, [desktopWindowStateChanged]);

return <CustomComponent {...desktopWindow} />;
};
```

2. **useDrag.tsx**
Expand Down Expand Up @@ -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); },
Expand All @@ -131,7 +132,9 @@ const BackgroundWindow = () => {
return () => stop();
}, [start, stop]);

return null;
}

```

4. **useRunningGame.tsx**
Expand All @@ -158,5 +161,3 @@ return <p>Alert Window</p>
## License

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

0 comments on commit 0d721a0

Please sign in to comment.