Skip to content

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)
ParameterTypeDescription
paramsToastParamsNotification 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: string

options

Notification display options of type ToastOptions

ts
options: ToastOptions

title

Notification title

ts
title: string

view

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(): void

show

Shows the notification with current view, title, message and options values

ts
async show(): Promise<any>

show() method events:

EventParameterTypeDescription
'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();

Published under the MIT license.