Skip to content

Commit 5c16f60

Browse files
committed
add method clear in index.js
1 parent 4acf22a commit 5c16f60

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@ const NotificationStore = {
1111
closeOnClick: true,
1212
showClose: true
1313
},
14-
setOptions (options) {
14+
setOptions(options) {
1515
this.settings = {...this.settings, ...options}
1616
},
17-
removeNotification (timestamp) {
17+
removeNotification(timestamp) {
1818
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)
2220
},
23-
addNotification(notification){
24-
if (typeof notification === 'string' || notification instanceof String){
21+
addNotification(notification) {
22+
if (typeof notification === 'string' || notification instanceof String) {
2523
notification = {message: notification}
2624
}
2725
notification.timestamp = new Date()
2826
notification.timestamp.setMilliseconds(notification.timestamp.getMilliseconds() + this.state.length)
2927
notification = {...this.settings, ...notification}
3028
this.state.push(notification)
3129
},
32-
notify (notification) {
30+
notify(notification) {
3331
if (Array.isArray(notification)) {
3432
notification.forEach((notificationInstance) => {
3533
this.addNotification(notificationInstance)
@@ -38,6 +36,9 @@ const NotificationStore = {
3836
this.addNotification(notification)
3937
}
4038

39+
},
40+
clear() {
41+
this.state = []
4142
}
4243
}
4344

0 commit comments

Comments
 (0)