Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-bluebird

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-bluebird

Angular Service for Bluebird

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

angular-bluebird

An AngularJS service for Bluebird promise library.

NOTE: Right now it's very experimental.

Why?

Because Bluebird is probably one of the best promise libraries around. Also, it IS the fastest.

Usage

npm install --save angular-bluebird

Example

This library assumes that you use Browserify

app.js:

var ngBluebird = require('angular-bluebird')

var app = angular.module('app', ['angular-bluebird'])
ngBluebird.trackDigests(app) //thank you http://stackoverflow.com/questions/23984471/how-do-i-use-bluebird-with-angular

// ....

some-ctrl.js:

function SomeCtrl($scope, $window, $timeout, $bluebird) {
  function asyncAskQuestion(question) {
    var deferred = $bluebird.defer

    $timeout(function() { //simulate async
      var result = $window.prompt(question)
      if (typeof result == 'string') { //OK Pressed
        deferred.resolve({okPresssed: true, answer: result})
      } else { //'Canceled Pressed'
        deferred.reject({okPressed: false})
      }
    }, 250)

    return deferred.promise
  }

  $scope.askQuestion = function() {
    var promise = asyncAskQuestion("Who is your favorite Teenage Mutant Ninja Turtle?")
    promise.then(function(result) { //success (i.e. resolve)
      $window.alert('Cowabunga! Your favorite turtle is ' + result.answer)
    }, function(result) { //failure (i.e. reject)
      $window.alert("You don't like the Ninja Turtles? What is wrong with you?")
    })
  }
} 

License

MIT

Keywords

FAQs

Package last updated on 02 Aug 2014

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