npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-bluebird-promises

v1.0.2

Published

Replaces $q with bluebirds promise API

Downloads

951

Readme

Angular bluebird promises

Build Status Bower version npm version devDependency Status Codacy Badge

This is a drop in replacement for $q that makes the bluebird API compatible with angulars subset of $q then simply swaps it out.

With this module you can use all of bluebirds additional promise methods on the $q service, the full list can be found here:

http://bluebirdjs.com/docs/api-reference.html

Installation

The library depends on angularJS and Bluebird.

It is recommended that you install the library and its dependencies through bower:

bower install --save angular-bluebird-promises

You will then need to include the JS files for the plugin:

<script src="bower_components/bluebird/js/browser/bluebird.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-bluebird-promises/dist/angular-bluebird-promises.min.js">

And finally add the module dependency in your AngularJS app:

angular.module('myApp', ['mwl.bluebird']);

Alternatively you can install through npm:

npm install --save angular-bluebird-promises

Then add as a dependency to your app:

angular.module('myApp', [require('angular-bluebird-promises')]);

Usage

Simply use $q as you normally would. It will function exactly as before, however you will now have bluebirds additional API methods available as well on all promises throughout your angular app.

Unhandled rejections

By default the value of onPossiblyUnhandledRejection is set to angular.noop. You can and should override this with your own handler in order to catch uncaught errors. For example:

angular.module('mwl.bluebird').run(function($q, $log) {
  $q.onPossiblyUnhandledRejection(function(err) {
    $log.warn('Unhandled rejection', err);
  });
});

If using the ui-router this will produce some noise. To get around this you can do something like:

$q.onPossiblyUnhandledRejection(function(exception) {
  if (exception.message.match(/transition (superseded|prevented|aborted|failed)/)) {
    return;
  }
  // Handle exception
});

Example

angular.module('mwl.example', ['mwl.bluebird']).run(function($q, $http) {

    var promises = [
        $http.get('test/angular.json'),
        $http.get('test/bluebird.json')
    ];

    //Note the use of spread which isn't available normally on $q
    $q.all(promises).spread(function(angular, bluebird) {

        console.info('\\m/ It worked! \\m/', angular.data.name, bluebird.data.name);

    }).catch(console.error);

});

Development

Prepare your environment

  • Install Node.js and NPM (should come with)
  • Install local dev dependencies: npm install while current directory is this repo

Build

Run npm run build to build the project files in the dist folder

Development server

Run npm start to start a development server with auto reload that will also run unit tests

License

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.