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

angular-q-spread

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-q-spread

Add `spread` method to the promise of $q.all

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
increased by7.69%
Maintainers
1
Weekly downloads
 
Created
Source

GitHub version Bower version NPM version

Build Status

angular-q-spread

Add spread method to the promise returned by $q.all.

spread can be used as a replacement for then. Similarly, it takes two parameters, a callback when all promises are resolved and a callback for failure. The resolve callback is going to be called with the result of the list of promises passed to $q.all as separate parameters instead of one parameters which is an array.

#Compatibility This plugin has been tested with Angular 1.2 and 1.3

#Usage Add $q-spread as dependency when creating your angular module.

#Example angular.module('test', ['$q-spread']);

function TestCtrl($scope, $q, MyService) {
    $scope.data1 = null;
    $scope.data2 = null;

    function dataSuccess(result1, result2) 
    {
        $scope.data1 = result1;
        $scope.data2 = result2;
    }
    
    function dataFailure(reason) 
    {
        alert('Could not load data: ' + reason);
    }
    
    $q
        .all([
            MyService.getData1(),
            MyService.getData2()
        ])
        .spread(dataSuccess, dataFailure);
};

TestCtrl.$inject = ['$scope', '$q', 'MyService'];

angular.module('test').controller('TestCtrl', TestCtrl);

License

This Angular module has been published under the MIT license

Keywords

FAQs

Package last updated on 08 Dec 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