npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

overwolf-hooks

v4.1.5

Published

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

Downloads

297

Readme

NPM JavaScript Style Guide

Install

$ npm install --save overwolf-hooks
$ pnpm install --save overwolf-hooks
$ yarn add overwolf-hooks

How to use

Hooks

  1. useWindow.tsx
import { useWindow } from 'overwolf-hooks';

const shouldDisplayLog = true;
const shouldListenToWindowStateChanges = true;

const Panel = () => {

const [desktopWindow] = useWindow("desktop", shouldDisplayLog,shouldListenToWindowStateChanges);

return (
    <div>
      <h1>Desktop Window</h1>
      <button onClick={()=> desktopWindow?.minimize()}>Minimize</button>
      <button onClick={()=> desktopWindow?.restore()}>Restore</button>
      <button onClick={()=> desktopWindow?.maximize()}>Maximize</button>
      <button onClick={()=> desktopWindow?.close()}>Close</button>
    </div>
  )
}

Force Window update

If you need to force update the window state, you can use the refreshState function.

import { useWindow } from "overwolf-hooks";

const shouldDisplayLog = true;
const shouldListenToWindowStateChanges = true;

//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
);

const Panel = () => {
  useEffect(() => {
    //........ any other code
    //force update/rebind the window object
    refreshState();
  }, [refreshState]);

  useEffect(() => {
    //........ any other code
    console.info("desktopWindowStateChanged", desktopWindowStateChanged);
  }, [desktopWindowStateChanged]);

  return <CustomComponent {...desktopWindow} />;
};
  1. useDrag.tsx
import { useEffect, useCallback } from "react";
import { useDrag, useWindow } from 'overwolf-hooks'

const shouldDisplayLog = true;

const Header = () => {

const [desktopWindow] = useWindow("desktop", shouldDisplayLog);
const { onDragStart, onMouseMove, setCurrentWindowID } = useDrag(null, shouldDisplayLog);

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

useEffect(updateDragWindow, [updateDragWindow])

return (
    <header
      onMouseDown={event => onDragStart(event)}
      onMouseMove={event => onMouseMove(event)}>
        Header Text
    </header>
  )
}
  1. useGameEventProvider.tsx
const REQUIRED_FEATURES = ["game_info", "match_info", "game_events"];
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); },
      onNewEvents: (events) =>  { console.log("events", events); }),
    },
    REQUIRED_FEATURES,
    RETRY_TIMES,
    DISPLAY_OVERWOLF_HOOKS_LOGS
  );

  useEffect(() => {
    start();
    return () => stop();
  }, [start, stop]);

  return null;
}
  1. useRunningGame.tsx
import { useEffect } from "react";
import { useGameEventProvider, useRunningGame } from 'overwolf-hooks'

const shouldDisplayLog = true;

const Alert = () => {

  const [currentGame] = useRunningGame(shouldDisplayLog);

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

return <p>Alert Window</p>

}

License

MIT © AlbericoD