Skip to content

Commit 9ae1ff1

Browse files
committed
update readme
1 parent 703a590 commit 9ae1ff1

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,60 @@ SignalsJS
99
[![Greenkeeper badge](https://badges.greenkeeper.io/RobotlegsJS/SignalsJS.svg)](https://greenkeeper.io/)
1010
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
1111

12-
TypeScript port of [AS3 Signals](https://github.com/robertpenner/as3-signals).
13-
[13kb compressed](dist/signals.min.js).
12+
**SignalsJS** is a [TypeScript](https://www.typescriptlang.org/) port of [AS3 Signals](https://github.com/robertpenner/as3-signals).
13+
[15KB compressed](dist/signals.min.js).
14+
15+
About
16+
---
17+
18+
**Signals** are light-weight, strongly-typed messaging tools.
19+
Wire your application with better APIs and less boilerplate than normal event systems.
20+
21+
Concept
22+
---
23+
24+
* A **Signal** is essentially a mini-dispatcher specific to one event, with its own array of listeners.
25+
* A **Signal** gives an event a concrete membership in a class.
26+
* Listeners subscribe to real objects, not to string-based channels.
27+
* Event string constants are no longer needed.
28+
* **Signals** are inspired by [C# events](http://en.wikipedia.org/wiki/C_Sharp_syntax#Events) and [signals/slots](http://en.wikipedia.org/wiki/Signals_and_slots) in Qt.
29+
30+
Syntax
31+
---
32+
33+
```typescript
34+
// with DOM EventListener
35+
button.addEventListener("click", onClick);
36+
37+
// Signal equivalent; past tense is recommended
38+
button.clicked.add(onClicked);
39+
```
40+
41+
Installation
42+
---
43+
44+
You can get the latest release and the type definitions using [NPM](https://www.npmjs.com/):
45+
46+
```bash
47+
npm install @robotlegsjs/signals
48+
```
49+
50+
Or using [Yarn](https://yarnpkg.com/en/):
51+
52+
```bash
53+
yarn add @robotlegsjs/signals
54+
````
1455

1556
Usage
1657
---
1758

18-
```ts
59+
```typescript
1960
import { Signal } from "@robotlegsjs/signals";
20-
var signal = new Signal();
61+
62+
let signal = new Signal();
2163
2264
signal.add(data => {
23-
console.log(data.message);
65+
console.log(data.message);
2466
});
2567
2668
signal.dispatch({ message: "hello signal!" });

0 commit comments

Comments
 (0)