angular-meteor-promiser
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -14,14 +14,8 @@ "use strict"; | ||
return this._promise(function (resolve, reject) { | ||
console.log('sub'); | ||
var handle = meteor_1.Meteor.subscribe.apply(meteor_1.Meteor, [name].concat(args, [{ | ||
onReady: function () { | ||
console.log('onready'); | ||
resolve(handle); | ||
}, | ||
onStop: function () { | ||
console.log('onstop'); | ||
reject(); | ||
}, | ||
onError: function () { | ||
console.log('onerror'); | ||
} | ||
@@ -63,6 +57,14 @@ }])); | ||
}; | ||
Promiser.prototype.any = function (fn) { | ||
return this._promise(function (resolve, reject) { | ||
try { | ||
resolve(fn()); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
}; | ||
Promiser.prototype._promise = function (fn) { | ||
var d = this.$q.defer(); | ||
fn(d.resolve, d.reject); | ||
return d.promise; | ||
return this.$q(fn); | ||
}; | ||
@@ -69,0 +71,0 @@ return Promiser; |
@@ -16,14 +16,8 @@ import * as angular from 'angular'; | ||
return this._promise((resolve, reject) => { | ||
console.log('sub'); | ||
const handle = Meteor.subscribe(name, ...args, { | ||
onReady() { | ||
console.log('onready'); | ||
resolve(handle); | ||
}, | ||
onStop() { | ||
console.log('onstop') | ||
reject(); | ||
}, | ||
onError() { | ||
console.log('onerror'); | ||
} | ||
@@ -58,8 +52,14 @@ }); | ||
public any(fn) { | ||
return this._promise((resolve, reject) => { | ||
try { | ||
resolve(fn()); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
private _promise(fn) { | ||
const d = this.$q.defer(); | ||
fn(d.resolve, d.reject); | ||
return d.promise; | ||
return this.$q(fn); | ||
} | ||
@@ -66,0 +66,0 @@ } |
{ | ||
"name": "angular-meteor-promiser", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Turns Meteor subscribe, call, apply callbacks into promises", | ||
@@ -5,0 +5,0 @@ "main": "angular-meteor-promiser.js", |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
7269
8
149
1
42