https://github.com/endel/strong-events
Lightweight Strong Typed Event Signaling for TypeScript
https://github.com/endel/strong-events
Last synced: about 1 year ago
JSON representation
Lightweight Strong Typed Event Signaling for TypeScript
- Host: GitHub
- URL: https://github.com/endel/strong-events
- Owner: endel
- License: mit
- Created: 2019-08-06T19:27:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:22:13.000Z (over 3 years ago)
- Last Synced: 2025-04-12T20:08:42.637Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 58.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strong-events
Lightweight Strong Typed Event Signaling for TypeScript / JavaScript.
## What is a Signal?
TODO
> https://github.com/millermedeiros/js-signals/wiki/Comparison-between-different-Observer-Pattern-implementations
## Installation
```
npm install strong-events
```
## Usage
```typescript
import { createSignal } from "strong-events";
const onSomeEvent = createSignal<(string) => void>();
// register a callback
onSomeEvent(function(value) {
console.log("event emitted with:", value);
});
// registering a callback to run just once
onSomeEvent.once(function(value) {
console.log("event emitted once, with:", value);
});
// invoke the event
onSomeEvent.invoke("triggering the event!");
```
## LICENSE
MIT.