forked from DuendeArchive/identity-model-oidc-client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.js
More file actions
30 lines (24 loc) · 719 Bytes
/
Event.js
File metadata and controls
30 lines (24 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
import Log from './Log';
export default class Event {
constructor(name) {
this._name = name;
this._callbacks = [];
}
addHandler(cb) {
this._callbacks.push(cb);
}
removeHandler(cb) {
var idx = this._callbacks.findIndex(item => item === cb);
if (idx >= 0) {
this._callbacks.splice(idx, 1);
}
}
raise(...params) {
Log.debug("Raising event: " + this._name);
for (var cb of this._callbacks) {
cb(...params);
}
}
}