# ste-simple-events

> Add the power of Simple Events to your projects. Every event has an argument with its data.

Latest version **3.0.11** (published 2023-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install ste-simple-events
pnpm add ste-simple-events
yarn add ste-simple-events
bun add ste-simple-events
```

## 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 | 3.0.11 |
| Published | 2023-08-09 |
| First published | 2018-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=4.2.4 |
| Dependencies | 1 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 139 |
| Author | Kees C. Bakker |
| Maintainers | keestalkstech |
| Keywords | signals, events, event, strongly, typed, typescript, DotNet |

## Links

- npm: https://www.npmjs.com/package/ste-simple-events
- Repository: https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript
- Homepage: https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript#readme
- Issues: https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript/issues
- npm.io page: https://npm.io/package/ste-simple-events

## Dependencies (1)

- [ste-core](https://npm.io/package/ste-core.md) ^3.0.11

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.0.11 (latest) — 2023-08-09
- 3.0.9 — 2023-01-24
- 3.0.8 — 2023-01-11
- 3.0.7 — 2022-10-29
- 3.0.6 — 2022-10-12
- 3.0.5 — 2022-09-01
- 3.0.4 — 2022-09-01
- 3.0.3 — 2022-06-14
- 3.0.2 — 2022-05-02
- 3.0.1 — 2022-03-23
- 2.1.16 — 2022-03-02
- 2.1.14 — 2021-11-10
- 2.1.13 — 2021-09-30
- 2.1.12 — 2021-09-28
- 2.1.11 — 2021-09-25
- … 61 more at https://npm.io/package/ste-simple-events/versions

## README

# Strongly Typed Events - Simple events
Simple events are a type of event that will provide an `argument` with data when fired. If you use typescript, you can leverage the support for generics and get strongly typed code.

Need a different type of event? Check out <a href="https://www.npmjs.com/package/strongly-typed-events">the others</a>.

[![Build Status](https://travis-ci.org/KeesCBakker/Strongly-Typed-Events-for-TypeScript.svg?branch=master)](https://travis-ci.org/KeesCBakker/Strongly-Typed-Events-for-TypeScript)
[![npm version](https://badge.fury.io/js/ste-signals.svg)](https://badge.fury.io/js/ste-signals)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

### Subscription made easy
An example says more than a 1000 words. Imagine if you have events like this on your class:
```typescript
let clock = new Clock("Smu", 1000);

//log the name of the clock and the tick argument to the console - this is an event
clock.onClockTick.subscribe((c, n) =>
  console.log(`${c.name} ticked ${n} times.`)
);
```

### Events made easy
So let's look at the implementation from a TypeScript perspective. (Do you program NodeJs without typescript? <a href="https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript/blob/master/documentation/HowToUseInNodeJs.md">Check this</a>)

```typescript
import { SimpleEventDispatcher } from "ste-simple-events";

class Clock {
  private _onSequenceTick = new SimpleEventDispatcher<number>();
  private _ticks: number = 0;

  constructor(public name: string, timeout: number) {
    setInterval(() => {
      this._ticks += 1;
      this._onSequenceTick.dispatch(this._ticks);
    }, timeout);
  }

  public get onSequenceTick() {
    return this._onSequenceTick.asEvent();
  }
}
```

Check the <a href="https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript/tree/master/documentation">documentation</a> or the <a href="https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript/tree/master/examples">examples</a> for more information.

Need more info? Check the <a href="https://github.com/KeesCBakker/Strongly-Typed-Events-for-TypeScript">repo</a>.

## Maintenance
This project is maintained by <a href="https://keestalkstech.com/">Kees C. Bakker</a>.

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