# @edunad/hooks

> LITE Unique Id observables

Latest version **1.0.1** (published 2021-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @edunad/hooks
pnpm add @edunad/hooks
yarn add @edunad/hooks
bun add @edunad/hooks
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-01-28 |
| First published | 2019-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Eduardo Fernandes |
| Maintainers | failcake |
| Keywords | hooks, observables, lite, global, garrysmod |

## Links

- npm: https://www.npmjs.com/package/@edunad/hooks
- Repository: https://github.com/edunad/hooks
- Issues: https://github.com/edunad/hooks/issues
- npm.io page: https://npm.io/package/@edunad/hooks

## Recent versions

- 1.0.1 (latest) — 2021-01-28
- 1.0.0 — 2020-06-25
- 0.0.4 — 2020-06-10
- 0.0.3 — 2019-07-11
- 0.0.2 — 2019-07-11
- 0.0.1 — 2019-07-11

## README

# hooks (Typescript)⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[![npm version](https://badge.fury.io/js/%40edunad%2Fhooks.svg)](https://badge.fury.io/js/%40edunad%2Fhooks) [![Coverage Status](https://coveralls.io/repos/github/edunad/hooks/badge.svg?branch=master)](https://coveralls.io/github/edunad/hooks?branch=master) [![Build Status](https://travis-ci.org/edunad/hooks.svg?branch=master)](https://travis-ci.org/edunad/hooks)
## **LITE Unique Id observables** based on [garrysmod hooks](https://wiki.garrysmod.com/page/hook)

## Installation
```
npm install @edunad/hooks
```

## Examples
>### Local Hooks
 ```
     class myclass {
         public hook: Hook<string> = new Hook<string>();
 
         public hello(): void {
             hook.emit('world'); // Transmit "world" to all subscriptions
         }
     }

     class mylistener {
         private hookSub: HookSubscription;
         public registerHooks(): void {
             this.hookSub = myclass.hook.add('my-unique-id', (t: string) = {
                 console.debug(t); // Will print "world"
             }); 
             
             // or

             this.hookSub = myclass.hook.addUnique((t: string) = {
                 console.debug(t); // Will print "world"
             });
         }
 
         public unsubHooks(): void {
             // Remove subscription
 
             hookSub.destroy(); // or
             hook.remove(hookSub); // or
             hook.remove('my-unique-id');
         }
     }
```

>### Global Hooks
```
    hooks.add('game-think', 'my-unique-hook', (t: string) = {
        console.debug(t); // Will print "world"
    });

    hooks.add('game-think', 'my-unique-hook-2', (t: string) = {
        console.debug(t); // Will print "world"
    });

    hooks.emit('game-think', 'world');
    hooks.remove('game-think', 'my-unique-hook'); // Remove hook
```

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