Skip to content

Custom hooks to help use overwolf api with the new react hooks technology.

License

Notifications You must be signed in to change notification settings

corey-pitzo/overwolf-hooks

 
 

Repository files navigation

Overwolf Hooks

Custom hooks to help use overwolf api with the new react hooks technology.

NPM JavaScript Style Guide

Install

npm install --save overwolf-hooks

How to use

Hooks

  1. useWindow.ts
import React from "react";
import { useWindow } from 'overwolf-hooks'

const Panel:FC = ()=>{
const [desktopWindow] = useWindow("desktop");

return <>
          <p>Desktop Window</p>
          <button onClick={()=> desktopWindow?.minimize()}>Minimize</button>
          <button onClick={()=> desktopWindow?.restore()}>Restore</button>
          <button onClick={()=> desktopWindow?.maximize()}>Maximize</button>
          <button onClick={()=> desktopWindow?.close()}>Close</button>
        </>
}
  1. useDrag.ts
import React,{ useCallback } from "react";
import { useDrag, useWindow } from 'overwolf-hooks'

const Header:FC = ()=>{
const [desktopWindow] = useWindow("desktop");
const { onDragStart, onMouseMove, setCurrentWindowID } = useDrag(null);

const updateDragWindow = useCallback(() => {
  if (desktopWindow?.id) setCurrentWindowID(desktopWindow.id);
}, [desktopWindow]);

return <header onMouseDown={event => onDragStart(event)} onMouseMove={event => onMouseMove(event)}>
          Header Text
        </header>
}
  1. useGameEventProvider.ts
import React,{ useEffect } from "react";
import { useGameEventProvider } from 'overwolf-hooks'

const Overlay:FC = ()=>{
const [{ event, info }, setGameFeatures] = useGameEventProvider<
    GameExample.Info,
    GameExample.Event
  >();

  useEffect(() => {
    console.info("event", event); // or use https://github.com/AlbericoD/overwolf-modern-react-boilerplate#-remote-redux-debug
  }, [event]);

  useEffect(() => {
    console.info("info", info); // or use https://github.com/AlbericoD/overwolf-modern-react-boilerplate#-remote-redux-debug
  }, [info]);

return <p>Overlay Window</p>

}
  1. useRunningGame.ts
import React,{ useEffect } from "react";
import { useGameEventProvider } from 'overwolf-hooks'

const Alert:FC = ()=>{
  const [currentGame] = useRunningGame();

  useEffect(() => {
    console.info("currentGame", currentGame);
  }, [currentGame]);

return <p>Alert Window</p>

}

License

MIT © AlbericoD

About

Custom hooks to help use overwolf api with the new react hooks technology.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 70.7%
  • JavaScript 24.2%
  • HTML 2.8%
  • CSS 2.3%