Skip to content

Toast ​

Toast — UI component for displaying notifications in the Flowlu platform interface.

ts
import { Toast } from '@flowlu/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 '@flowlu/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.FlowluMiniApp;

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.