Skip to main content

@rtorcato/browser-common / alert

alert

Functions

showAlert()

showAlert(message): void

Defined in: alert/index.ts:10

Shows a browser alert dialog with a message.

Parameters

message

string

The message to display.

Returns

void

Example

import { showAlert } from '@rtorcato/browser-common/alert'
showAlert('Saved!')

showConfirm()

showConfirm(message): boolean

Defined in: alert/index.ts:24

Shows a browser confirm dialog and returns true if the user clicks OK.

Parameters

message

string

The message to display.

Returns

boolean

True if OK was clicked, false if Cancel.

Example

import { showConfirm } from '@rtorcato/browser-common/alert'
if (showConfirm('Delete item?')) deleteItem()

showPrompt()

showPrompt(message, defaultValue?): string | null

Defined in: alert/index.ts:39

Shows a browser prompt dialog and returns the user input or null if cancelled.

Parameters

message

string

The message to display.

defaultValue?

string

The default value for the input (optional).

Returns

string | null

The user input or null.

Example

import { showPrompt } from '@rtorcato/browser-common/alert'
const name = showPrompt('Your name?', 'Anon')