GithubHelp home page GithubHelp logo

ntsd / overwolf-nanostores Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 54 KB

Nano Stores implement for Overwolf

Home Page: https://ntsd.github.io/overwolf-nanostores/

License: MIT License

TypeScript 100.00%
hearthstone league-of-legends nanostores overlay overwolf game-overlay

overwolf-nanostores's Introduction

Overwolf Nano Stores

npm version

Nano Stores implementation for Overwolf Plugin

Prerequisite

Nano Stores is a powerful state manager library designed to support multiple frontend frameworks and tiny bundle sizes.

To have Overwolf API such as Window, Game Event stored in Nano Stores is an easy way to use the API and handle the state.

Supported frameworks: React, React Native, Preact, Vue, Svelte, Solid, Lit, Angular, and vanilla JS.

See how to use Nano Stores in a different framework at The Nano Store Guide.

Installation

npm i overwolf-nanostores

Documentation

Link: https://ntsd.github.io/overwolf-nanostores

Documentation is generated by TypeDoc.

Examples

Example for League of Legends game

import {
  setGameEventRequiredFeatures,
  gameInfoAtom,
  gameEventAtom,
} from "overwolf-nanostores";

// Set required event features
// check different game features from the Overwolf Docs
// https://overwolf.github.io/api/live-game-data/supported-games/league-of-legends#available-features
setGameEventRequiredFeatures(["gep_internal", "match_info", "chat"]);

// The subscribe will trigger every time when the Game Info is updated
gameInfoAtom.subscribe((newInfo) => {
  if (!newInfo) return;
   // use condition to check the feature name
  if (newInfo.feature === "gep_internal") {
    console.log("Local + Public version number:", JSON.stringify(newInfo.info));
  }
  if (newInfo.feature === "match_info") {
    console.log("match info:", JSON.stringify(newInfo.info));
  }
});

// The subscribe will trigger every time when a new Game Event occurs
gameEventAtom.subscribe((newEvent) => {
  if (!newEvent) return;
  newEvent.events.forEach((event) => {
    // use condition to check the event name
    if (event.name === "chat") {
      console.log("new chat:", event.data);
    }
  });
});

In the example,

gep_internal and match_info are features for Game Info so they will trigger the gameInfoAtom

chat is a feature for Game Event so it will trigger the gameEventAtom

overwolf-nanostores's People

Contributors

ntsd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.