Appearance
Callbacks
Usage
Any push method to create notifications accepts onAutoClear and onManualClear properties to execute some code when the notification is removed from the DOM.
Note
A notification can be removed either automatically (onAutoClear, when its timeout is reached) or manually (onManualClear, when the notification is dismissed or programatically cleared).
It's impossible that both callbacks are executed for the same notification.
Static notifications
ts
push.success({
message: 'Welcome back, you can now access your account.',
props: {
myCustomProp: true
},
onAutoClear(item) {
console.log('Auto cleared!')
console.log(item.message) // 'Welcome back, you can now access your account.'
},
onManualClear(item) {
console.log('Manually cleared!')
console.log(item.props.myCustomProp) // true
}
})Promise-based notifications
ts
const notification = push.promise({
message: 'Sending message, please hold on...',
onAutoClear(item) {
console.log(item.type) // 'promise-resolve'
console.log(item.message) // 'Your message has been successfully sent.'
},
onManualClear(item) {
console.log(item.type) // 'promise-resolve'
console.log('Resolved and cleared by user!')
}
})
notification.resolve('Your message has been successfully sent.')