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.

Example

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

Parameters

message

string

The message to display.

Returns

void


showConfirm()

showConfirm(message): boolean

Defined in: alert/index.ts:27

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

Example

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

Parameters

message

string

The message to display.

Returns

boolean

True if OK was clicked, false if Cancel.


showPrompt()

showPrompt(message, defaultValue?): string | null

Defined in: alert/index.ts:45

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

Example

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

Parameters

message

string

The message to display.

defaultValue?

string

The default value for the input (optional).

Returns

string | null

The user input or null.