Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class Event5 extends AbstractEvent<string> {
}
```

When redispatching an event, you must call `event.clone()`. The same instance cannot be redispatched. When the event is cloned, all constructor parameters are shallow-copied.
When redispatching an event, you must call `event.clone()`. The same instance
cannot be redispatched. When the event is cloned, all constructor parameters are
shallow-copied.

### `Evented`

We combine `Evented` with `AbstractEvent` to gain type-safety and convenience of the wildcard any handler.
We combine `Evented` with `AbstractEvent` to gain type-safety and convenience of
the wildcard any handler.

```ts
class EventCustom extends AbstractEvent {}
Expand Down Expand Up @@ -62,9 +65,13 @@ x.addEventListener(EventAll.name, (e) => {
});
```

You can use this style to handle relevant events to perform side-effects, as well as propagate upwards irrelevant events.
You can use this style to handle relevant events to perform side-effects, as
well as propagate upwards irrelevant events.

Note that some side-effects you perform may trigger an infinite loop by causing something to emit the specific event type that you are handling. In these cases you should specialise handling of those events with a `once: true` option, so that they are only handled once.
Note that some side-effects you perform may trigger an infinite loop by causing
something to emit the specific event type that you are handling. In these cases
you should specialise handling of those events with a `once: true` option, so
that they are only handled once.

```ts
x.addEventListener(
Expand All @@ -79,9 +86,12 @@ x.addEventListener(

This will terminate the infinite loop on the first time it gets handled.

Therefore it is a good idea to always be as specific with your event types as possible.
Therefore it is a good idea to always be as specific with your event types as
possible.

Furthermore any unhandled rejections or uncaught exceptions will be redispatched as `EventError`. However if there's no listener registered for this, it will be thrown up as an uncaught exception.
Furthermore any unhandled rejections or uncaught exceptions will be redispatched
as `EventError`. However if there's no listener registered for this, it will be
thrown up as an uncaught exception.

## Installation

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
},
"devDependencies": {
"@matrixai/lint": "^0.2.6",
"@matrixai/lint": "^0.2.11",
"@swc/core": "1.3.82",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.2",
Expand Down
Loading