konstantinkrassmann / ngCordova-nfc

Wrapper for the NFC functionality
MIT License
11 stars 4 forks source link

Sugar: load all components #7

Closed Phoscur closed 7 years ago

Phoscur commented 9 years ago

Instead of

$cordovaNfc.then(function(nfcInstance) {
  return $cordovaNfcNdef.then(function(ndef) {
    return $cordovaNfcUtil.then(function(util) {
      // code...

I'd like to propose this sugar to get ndef and util bundled onto nfcInstance:

services.service('cordovaNFC', ['$q', '$cordovaNfc', '$cordovaNfcNDef', '$cordovaNfcUtil', function ($q, $cordovaNfc, $cordovaNfcNDef, $cordovaNfcUtil) {
    return $q.all(
      [$cordovaNfc, $cordovaNfcNDef, $cordovaNfcUtil]).then(function (all) {
        var nfc = all[0];
        nfc.ndef = all[1];
        nfc.util = all[2];
        return nfc;
      });
  }])
konstantinkrassmann commented 7 years ago

PR