angular-meteor-promiser
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

angular-meteor-promiser

Turns Meteor subscribe, call, apply callbacks into promises

Install

npm install angular-meteor-promiser
angular.module('app', [
  'angular-meteor-promiser'
]);

$promiser

function controller($promiser) {
  // $promiser.subscribe
  // $promiser.call
  // $promiser.apply
  // $promiser.any
}

subscribe

Same arguments as Meteor.subscribe but without callback.

resolve() receives a handle that provides stop() and ready() methods.

call

Same arguments as Meteor.call.

apply

Same arguments as Meteor.apply.

any (sync and async)

function foo(bar) {
  if (!bar) {
    throw new Error('Bar, we need you!');
  }
 
  return bar;
}
 
$promiser.any(() => {
 
  return foo('sync');
 
})
  .then((data) => { ... }) // 'sync'
  .catch((error) => { ... });
 
 
$promiser.any((resolve, reject) => {
 
  setTimeout(() => {
    resolve(foo('async'));
  }, 500);
 
})
  .then((data) => { ... }) // 'async'
  .catch((error) => { ... });

Package Sidebar

Install

npm i angular-meteor-promiser

Weekly Downloads

2

Version

1.1.0

License

ISC

Last publish

Collaborators

  • kamilkisiela