https://github.com/inambe/hotvar-js
https://github.com/inambe/hotvar-js
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/inambe/hotvar-js
- Owner: Inambe
- Created: 2024-09-02T22:37:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-06T16:21:35.000Z (almost 2 years ago)
- Last Synced: 2025-02-01T14:17:00.028Z (over 1 year ago)
- Language: TypeScript
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hotvar-js
NPM package to use [hotvar.com](https://hotvar.com) in JavaScript environments.
# What's included?
This package exports `HotVar` class which allows using of "variables" created on [hotvar.com](https://hotvar.com)
## `HotVar` class
### `constructor(options: Partial = {})`
The constructor takes a config object. Here's the config object with defaults:
```
const onVar new HotVar({
/*
enable real-time updates
*/
live: false,
/*
default variables to get values of / listen
*/
vars: [],
/*
the mode it's running in. `html` indicates it'll search for variables in the page and replace their contents with variables' values
*/
mode: "html",
/*
function that gets called every time there's an update for variables. also runs when it first fetches the values
*/
onChange: undefined
})
```
### `fetchMany(varNames: string[]): Values`
### `fetchOne(varName: string): ValueResponse`
### `destroy(): void`
Destroys socket connection if `live` was `true`.