-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNotify.js
37 lines (31 loc) · 1.04 KB
/
Notify.js
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
31
32
33
34
35
36
37
const NotifySound = require('./NotifySound');
let id = 0;
module.exports = class Notify {
/**
* @param {string} title Title of notify
* @param {string} body Body of notify
* @param {number} time Duration of notification display in seconds
* @param {string} imageUrl Link to image of notification (file:// or http(s):// or another protocol)
* @param {NotifySound} sound Sound to play when a notification is shown
*/
constructor(title, body, time = 10, imageUrl = null, sound = null) {
this.id = id++;
this.title = title;
this.body = body;
this.time = time;
this.image = imageUrl;
this.sound = sound;
this.destroyed = false;
this.destroyEvents = [];
}
isDestroyed() {
return this.destroyed;
}
onDestroy(func) {
if (typeof func != 'function') {
console.error('func is not a function');
return;
}
this.destroyEvents.push(func);
}
};