New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-defer-alert

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-defer-alert

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

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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);
    });

Keywords

FAQs

Package last updated on 19 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc