# angular-defer-alert

> Angular service to promisify $window alerts, confirms and prompts.

Latest version **0.0.1** (published 2015-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install angular-defer-alert
pnpm add angular-defer-alert
yarn add angular-defer-alert
bun add angular-defer-alert
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-11-19 |
| First published | 2015-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Adam Weeks |
| Maintainers | adamweeks |
| Keywords | angular, promise, alert, window, confirm, prompt |

## Links

- npm: https://www.npmjs.com/package/angular-defer-alert
- Repository: https://github.com/adamweeks/angular-defer-alert
- Homepage: https://github.com/adamweeks/angular-defer-alert#readme
- Issues: https://github.com/adamweeks/angular-defer-alert/issues
- npm.io page: https://npm.io/package/angular-defer-alert

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2015-11-19

## README

# angular-defer-alert
Angular service to promisify $window alerts, confirms and prompts.

## Proposal
Do you want to use `$window.confirm` in a promise chain, but are too lazy to figure out how?
Well then, this is the service for you!

## Usage

### Confirms
Confirmations are great to insert in a process. They resolve successfully with an "OK" click. They are rejected when a user clicks "Cancel".
```
MyDonutService
  .getDonuts(12)
  .then(function(donutsFetched) {
    var confirmMessage = 'Are you sure you want to eat ' + donutsFetched + ' donuts?';
    DeferAlertService.openConfirm(confirmMessage)
      .then(function() {
        // User wants to eat donuts!
        return true;
      })
      .catch(function() {
        // User does not want to eat donuts
        return false;
      });
    });
```

### Prompts
Prompts ask a user for input before continuing. They resolve successfully with an "OK" click and provide the entered value. They are rejected when a user clicks "Cancel".
```
var promptMesage = 'How many donuts do you want to eat?';
var defaultValue = '12';
DeferAlertService.openPrompt(promptMessage, defaultValue)
  .then(function(donutAmount) {
    MyDonutService
    .getDonuts(donutAmount)
    .then(function(donutsFetched) {
      var confirmMessage = 'Are you sure you want to eat ' + donutsFetched + ' donuts?';
      DeferAlertService.openConfirm(confirmMessage)
        .then(function() {
          // User wants to eat donuts!
          return true;
        })
        .catch(function() {
          // User does not want to eat donuts
          return false;
        });
      });
  });
```

### Alerts
Since alerts don't really require a promise, we immediately resolve them, making for a very boring demo.
```
MyAwesomeService
  .doThing()
  .then(function(textToAlert) {
    DeferAlertService.openAlert(textToAlert);
    });
```

---
_Source: https://npm.io/package/angular-defer-alert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
