UNPKG
snow-falls
Version:
latest (1.2.0)
1.2.0
1.0.1
1.0.0
The snow falls and the wind blows
github.com/cct124/snow-falls
cct124/snow-falls
snow-falls
/
src
/
script
/
graphics
/
Event.ts
17 lines
(14 loc)
•
297 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export
default
class
Event
<T> {
private
events =
new
Set
<
(
evt
: T
) =>
void
>();
constructor
(
) {}
add
(
fn
: (evt: T) =>
void
) {
this
.
events
.
add
(fn);
return
() =>
this
.
events
.
delete
(fn); }
run
(
evt
: T
) {
this
.
events
.
forEach
(
(
fn
) =>
{
fn
(evt); });
return
true
; } }