Toast
Toast — UI component for displaying notifications in the Аспро.Cloud platform interface.
ts
import { Toast } from '@aspro-cloud/miniapp-jssdk'Constructor
Creates a Toast instance with the given parameters
ts
constructor(params: ToastParams)| Parameter | Type | Description |
|---|---|---|
params | ToastParams | Notification creation parameters |
Properties
events
Object of type EventCallbacks<ToastEventName> with notification event handlers
ts
get events(): EventCallbacks
set events(value: EventCallbacks)message
Notification message text
ts
message: stringoptions
Notification display options of type ToastOptions
ts
options: ToastOptionstitle
Notification title
ts
title: stringview
Notification view of type ToastView
ts
get view(): ToastView
set view(value: ToastView)Methods
clear
Hides all notifications
ts
static clear(): Promise<any>destroy
Removes subscriptions and frees resources
ts
destroy(): voidshow
Shows the notification with current view, title, message and options values
ts
async show(): Promise<any>show() method events:
| Event | Parameter | Type | Description |
|---|---|---|---|
'onShow' | Notification is shown | ||
'onHide' | Notification is hidden | ||
'onClose' | Notification is closed by user |
Example
ts
import { App, Toast } from '@aspro-cloud/miniapp-jssdk'
await App.initializeFrame()
const toast = new Toast({
view: 'success',
title: 'Saved',
message: 'Settings successfully updated',
options: {
timeOut: 5000
},
events: {
onShow: () => console.log('Notification shown'),
onHide: () => console.log('Notification hidden'),
onClose: () => console.log('Notification closed by user')
}
})
await toast.show()js
const App = window.ACloudMiniApp;
await App.initializeFrame();
const toast = new App.Frame.Toast({
view: 'success',
title: 'Saved',
message: 'Settings successfully updated',
options: {
timeOut: 5000
},
events: {
onShow: () => console.log('Notification shown'),
onHide: () => console.log('Notification hidden'),
onClose: () => console.log('Notification closed by user')
}
});
await toast.show();