@@ -11,25 +11,23 @@ const NotificationStore = {
11
11
closeOnClick : true ,
12
12
showClose : true
13
13
} ,
14
- setOptions ( options ) {
14
+ setOptions ( options ) {
15
15
this . settings = { ...this . settings , ...options }
16
16
} ,
17
- removeNotification ( timestamp ) {
17
+ removeNotification ( timestamp ) {
18
18
const indexToDelete = this . state . findIndex ( n => n . timestamp === timestamp )
19
- if ( indexToDelete !== - 1 ) {
20
- this . state . splice ( indexToDelete , 1 )
21
- }
19
+ if ( indexToDelete !== - 1 ) this . state . splice ( indexToDelete , 1 )
22
20
} ,
23
- addNotification ( notification ) {
24
- if ( typeof notification === 'string' || notification instanceof String ) {
21
+ addNotification ( notification ) {
22
+ if ( typeof notification === 'string' || notification instanceof String ) {
25
23
notification = { message : notification }
26
24
}
27
25
notification . timestamp = new Date ( )
28
26
notification . timestamp . setMilliseconds ( notification . timestamp . getMilliseconds ( ) + this . state . length )
29
27
notification = { ...this . settings , ...notification }
30
28
this . state . push ( notification )
31
29
} ,
32
- notify ( notification ) {
30
+ notify ( notification ) {
33
31
if ( Array . isArray ( notification ) ) {
34
32
notification . forEach ( ( notificationInstance ) => {
35
33
this . addNotification ( notificationInstance )
@@ -38,6 +36,9 @@ const NotificationStore = {
38
36
this . addNotification ( notification )
39
37
}
40
38
39
+ } ,
40
+ clear ( ) {
41
+ this . state = [ ]
41
42
}
42
43
}
43
44
0 commit comments