eLabSDK2.UI.Toast

Properties

showToast

Static showToast: (message: string, autoclose?: number, onOpen?: () => unknown, onClose?: () => unknown) => void

Type declaration

(message, autoclose?, onOpen?, onClose?): void

Display a toast notification message in the bottom right corner of the screen.

Toast notifications are lightweight, temporary messages that provide feedback to users about actions they've taken. They appear in the bottom right corner and can auto-close after a specified duration or remain visible until manually dismissed. Use toasts for success confirmations, informational messages, or non-critical notifications.

Parameters
NameTypeDescription
messagestringThe text message to display in the toast notification.
autoclose?numberOptional number of milliseconds after which the toast automatically closes. If not provided, the toast remains visible until manually dismissed.
onOpen?() => unknownOptional callback function that is triggered when the toast opens/appears.
onClose?() => unknownOptional callback function that is triggered when the toast closes/disappears.
Returns

void

Example

// Show a simple success message that auto-closes after 3 seconds
eLabSDK2.UI.Toast.showToast('Sample created successfully!', 3000);

Example

// Show a message that stays open until user dismisses it
eLabSDK2.UI.Toast.showToast('Please review the changes before proceeding.');

Example

// Show a message with callbacks
eLabSDK2.UI.Toast.showToast(
  'File upload in progress...',
  5000,
  () => console.log('Toast opened'),
  () => console.log('Toast closed')
);

Example

// Use after an async operation
async function createSample() {
  try {
    await api.createSample(sampleData);
    eLabSDK2.UI.Toast.showToast('Sample created successfully!', 3000);
  } catch (error) {
    eLabSDK2.UI.Toast.showToast('Failed to create sample. Please try again.');
  }
}

© 2023 eLabNext