# @nuskin/events

> The description that will amaze and astound your audience when they read it

Latest version **1.0.5** (published 2025-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nuskin/events
pnpm add @nuskin/events
yarn add @nuskin/events
bun add @nuskin/events
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2025-08-28 |
| First published | 2023-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Treg Anderson |
| Maintainers | nkranendonk, emoore, nuskin-cws, klau, rellenberger, aallani |

## Links

- npm: https://www.npmjs.com/package/@nuskin/events
- Repository: git@code.tls.nuskin.io:ns-am/utility/npm/events
- Homepage: https://code.tls.nuskin.io/ns-am/utility/npm/events/-/blob/master/README.md
- npm.io page: https://npm.io/package/@nuskin/events

## Dependencies (1)

- [pubsub-js](https://npm.io/package/pubsub-js.md) 1.9.5

## Recent versions

- 1.0.5 (latest) — 2025-08-28
- 1.0.3-cx16-8633.1 (prerelease) — 2023-04-04
- 1.0.4 — 2023-04-18
- 1.0.3 — 2023-04-05
- 1.0.2 — 2023-03-19
- 1.0.1 — 2023-03-01
- 1.0.1-cx16-8393.1 — 2023-02-28
- 1.0.0 — 2023-02-24
- 1.0.0-cx16-8326.6 — 2023-02-21
- 1.0.0-cx16-8326.5 — 2023-02-21
- 1.0.0-cx16-8326.4 — 2023-02-21
- 1.0.0-cx16-8326.3 — 2023-02-21
- 1.0.0-cx16-8326.2 — 2023-02-21
- 1.0.0-cx16-8326.1 — 2023-02-20

## README

# @nuskin/events

"This is a replacement for the pub/sub functionality that has been used from nuskinjquery.
It includes the same functionality as what was there and the main use of this is in @nuskin/ns-util - events.js
where nuskinjquery was used."

## Installing

Usng npm:

```bash
npm add @nuskin/events
```

Usng yarn:

```bash
yarn add @nuskin/events
```

## Example usage

```js
const {
    subscribe,
    publish,
    unsubscribe,
    getValue,
    setValue,
} = require('@nuskin/events');


// Publishes value to listeners on the eventId event.
// value is optional and if not specified it will come through
// as true to the listeners.
//
// If an array is being passed into value then it needs to be
// surrounded by []. The code uses the first element of the array
// to publish to the listeners.
publish(eventId, value);

const testCallback = (value) => {
  // do something with value
};

// sets up the testCallback function to listen on
subscribe(eventId, testCallback);

// This will take the testCallback function off of the eventId listeners.
unsubscribe(eventId, testCallback);

// This will set a value in state to be retrieved by getValue.
// This will also publish value to listeners on eventId.
setValue(eventId, value);

// This will call testCallback with the current value set in start by setValue.
// The third parameter is default to false. If it is set to true then it will
// also subscribe to future values publish/setValue to listeners on eventId
getValue(eventId, testCallback, true);
```

## Resources

## License

[MIT](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/@nuskin/events · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
