alert
Thin wrappers around the browser's alert, confirm, and prompt dialogs.
Import: @rtorcato/browser-common/alert
showAlert, showConfirm, and showPrompt all throw a
requires a browser environment error when called outside a browser (no
window) — there is no feature-check function, so guard with your own
environment check if you might run this code server-side.
Example
import { showAlert, showConfirm, showPrompt } from '@rtorcato/browser-common/alert'
showAlert('Saved!')
if (showConfirm('Delete item?')) {
deleteItem()
}
const name = showPrompt('Your name?', 'Anon')
Exports
showAlert(message)— shows an alert dialogshowConfirm(message)— shows a confirm dialog, returnstrueif OK was clickedshowPrompt(message, defaultValue?)— shows a prompt dialog, returns the input ornull
See the API reference for full signatures.