Skip to content

Events

SDK exports common event types and event name enumerations for class methods:

ts
import type {
  EventCallback,
  EventCallbacks,
  FrameEventName,
  FrameOpenUrlEventName,
  FrameOpenHomepageEventName,
  OAuth2EventName,
  ToastEventName,
  SwalEventName,
  ModalEventName,
  SidepanelEventName
} from '@aspro-cloud/miniapp-jssdk'

Types

EventCallback

Event callback function

ts
type EventCallback<T = any> = (data: T) => void
ParameterTypeDescription
dataanyEvent data

EventCallbacks

Object with event handlers, passed in method and constructor parameters

ts
type EventCallbacks<TEventName extends string = string> =
  Partial<Record<TEventName, EventCallback<any> | null>> | null
PropertyTypeDescription
[eventName: string]EventCallback | nullEvent handler

FrameEventName

Event names for Frame.initialize()

ValueDescription
'onReady'Fired after iframe content is loaded (DOMContentLoaded), Frame is initialized and context is received, embedded content is displayed

FrameOpenUrlEventName

Event names for Frame.openUrl()

ValueDescription
'onOpen'URL opened
'onCancel'URL opening cancelled

FrameOpenHomepageEventName

Event names for Frame.openHomepage()

ValueDescription
'onOpen'Application homepage opened
'onCancel'Opening cancelled

OAuth2EventName

Event names for OAuth2.refresh()

ValueDescription
'onRefresh'Tokens successfully refreshed

ToastEventName

Event names for Toast.show()

ValueDescription
'onShow'Notification is shown
'onHide'Notification is hidden
'onClose'Notification is closed by user

SwalEventName

Event names for Swal.alert()

ValueDescription
'onShow'Dialog is shown
'onHide'Dialog is hidden
'onCancel'User cancelled the action

Event names for Swal.confirm()

ValueDescription
'onShow'Dialog is shown
'onHide'Dialog is hidden
'onCancel'User cancelled the action
'onConfirm'User confirmed the action

Event names for Swal.prompt()

ValueDescription
'onShow'Dialog is shown
'onHide'Dialog is hidden
'onCancel'User cancelled the action
'onPrompt'User entered a value

ModalEventName

Event names for Modal.show()

ValueDescription
'onShow'Modal window is shown
'onHide'Modal window is hidden
'onClose'Modal window is closed by user

SidepanelEventName

Event names for Sidepanel.show()

ValueDescription
'onShow'Side panel is shown
'onHide'Side panel is hidden
'onClose'Side panel is closed by user

Published under the MIT license.