deanrad / meteor-promise Goto Github PK
View Code? Open in Web Editor NEWUtilities for Promise-based wrappers, method calls, helpers and HTTP in Meteor
Utilities for Promise-based wrappers, method calls, helpers and HTTP in Meteor
Just a heads up the link to the demo/docs is no longer working.
got errors like: TypeError: Promise.asyncApply is not a function
every time invoke Meteor.callPromise
hi,
after the upgrade there's no return value from the promise function: .then(myFunc())
...
Meteor.promise ("...", ...)
.then (myFunc ())
.done (function () {..})
.fail (function (err) {console.error ("Bad", err);})
...
function myFunc (myParam) {
myParam comes as undefined
...
}
myParam is 'undefined' whereas the promise method should return it
I can see that the method is called and there's the value which is to be received back, this worked before nicely
it worked before the upgrade, I couldn't figure out based on the release notes what was the change which resulted in my issue
what do you think what do problem could be?
thanks a lot
Just upgraded from 1.3-beta.12
to 1.3-rc.2
and now I get the following error
While processing files with cosmos:browserify (for target web.browser):
packages/deanius:promise/client/runAsync.browserify.js: Cannot read
property '0' of undefined
EDIT: The error is present outside of testing as well.
Hi,
I use to use this package in my Meteor 2.x apps, and I got a version 3.1.0 last time I `meteor add deanius:promise'.
I just created a new Meteor 3.0-rc.2 application, and tried to pull the package as usual.
But this time, I get a v 2.3.1 version, which seems bad as I see here in Github that last version is 3.1.6.
So I do not understand what happens ?
Maybe the package is no more published to atmosphere or so ?
Could you please be kind enough to clarify the status ?
Thanks in advance.
Regards
Pierre
I was wondering if you'd consider providing HTTP.callPromise on the server so its possible to use the same code on the client and the server without re-writing it. We often move bits of code between each and we're therefore trying to write code that runs in each.
Hi! Great package.
I'd like to be able to use this for subscriptions as well:
Meteor.subscibePromise("myData").then(function () {
// Now I have my data!
});
Basically, it should track the ready()
handle on the subscription, and fire the promise when the subscription is ready.
I'm a bit confused (NB this is my first Meteor project, so I may be totally out to lunch on this...)
meteor add deanius:promises
and see deanius:promise
in .meteor/packagesfunction kcommand(cmd) {
return new Promise( function(resolve,reject){
resolve("Cmd was %{cmd}"); // just a stub for a functioning method
});
foo = Meteor.callPromise('kcommand', 'kVersion');
Many thanks.
I would like to return array()
from `Meteor.methods().
Could or not.
Please help me.
catch
)Hi, I'm wondering if there will be any plans to support promises on React. I'm thinking in something like this:
Session.set 'arg1', 1
Session.set 'arg2', 2
@Main = React.createClass
mixins : [ReactMeteorData]
getMeteorData: ->
data = {}
arg1 = Session.get 'arg1'
arg2 = Session.get 'arg2'
data.promise = Meteor.call('add', arg1, arg2)
data
render: ->
<div>
hello: {@data.promise}
</div>
Thanks.
Hi @chicagogrooves , idea is nice but it doesnt work server side because of Meteor.bindEnvironment.
Lets try your example server side :
Meteor.promise("createCustomer", "[email protected]", "VISA")
.then(Meteor.bindEnvironment(function(customer) {
return Meteor.promise("createCustomerSubscription", customer.id, plan);
}))
.then(Meteor.bindEnvironment(function(plan) {
console.log("Plan", plan);
}))
.catch(Meteor.bindEnvironment(function (err) {
console.error(err);
}))
what we can see ? in third promise plan is undefined , it is called before any output from createCustomerSubscription
.
I notice there's some compatibility improvements in master that aren't published as a package. Can you publish the latest update? Thanks!
Hi, I wonder if we should update the syntax of the promises, once we replace to the okgrow:promise package can any promise broke? I ask this since I have more than +300 promises in my app it is pretty big so Im afraid to update to the new package and broke my current promises that are working ok.
Looked at the compiled result and saw 'es6-promises'. Checked out es6-promises which is a subset of rsvp. I checked out those docs and noticed there is a finally
callback, which is what I was looking for, but it doesn't seem to work.
IonLoading.show();
Meteor.promise('createOrder', orderId, address)
.then(function (order) {
return Meteor.promise('createShipment', order)
})
.then(function (shipment) {
return Meteor.promise('chargeOrder', shipment)
})
.then(function () {
Router.go(nextRoute);
});
.catch(function (err) {
Orders.unset(orderId, {
shipment: "",
address: ""
});
sAlert.error("Failed to create and charge order");
})
.finally(function () {
IonLoading.hide();
});
The traceback is like so:
Meteor.promise(...).then(...).then(...).then(...).catch(...).finally is not a function
It don't show loading...
alert:
// Server
Meteor.methods({
getData: function(){
var data = MyCollection.find(); // 10000 docs
return data;
}
})
// Client
<template name="myTpl">
// each data
</template>
Template.myTpl.helpers({
data: ReactivePromise(function(){
var data = Meteor.promise('getData');
return data;
}, 'loading...');
})
Please help me.
hi,
with the previous meteor and promise 1.0.2 app was working fine
any idea where to look for the issue?
Exception in template helper: TypeError: undefined is not a function
at Object.Template.map.helpers.aroundMe (http://localhost:3000/client/map.js?7f597dfa16c11bdf0bd700eb491b6e3d0b5402e1:158:10)
at bindDataContext (http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2786:16)
at Blaze._wrapCatchingExceptions (http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1607:16)
at http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2834:66
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:12)
at wrapHelper (http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2833:27)
at Spacebars.call (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:18)
at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:109:25)
at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:113:39)
at null._render (http://localhost:3000/client/template.hvg.js?4a5bfceb447b1d5ae38a17224736e41b171cf85f:33:22)
map.js 158:10 is the line of .done ()
thanks a lot,
tinto
Hello @deanius !
Thanks for the awesome package.
There is a way to use Promise.all
like for readyPromise() ?
I have a few this.subscribes
in my onCreated hook.
Would like to wait them all to be ready so I can use the data.
Meteor collection methods currently use a callback, can they be converted to a promise?
Why it always show
helper run for Array[0]
promiseHelper.js:25 evaluating helper []
promiseHelper.js:40 Promise resolved [] foo, bar
Could I clear.
Looks like I'm not sure how to follow your example, I get errors like TypeError: Object #<Promise> has no method 'done'
and [TypeError: Object #<Object> has no method 'then']
while trying to arrange things properly.
Following along the meteor chef example for Stripe integration, here's my failing code:
Meteor.methods({
createSubscription: function(customer) {
var user = Meteor.users.findOne({_id: customer.userId});
var getCustomer = function(customer){
return Meteor.promise("stripeCreateCustomer", customer);
};
var getSubscription = function(stripeCustomer){
return Meteor.promise("stripeCreateSubscription", stripeCustomer.id, customer.plan)
};
Meteor.promise("getCustomer")
.then(getSubscription)
.catch(function(err){
console.log(err);
})
.done(function(customer){
console.log("promise complete ", customer);
})
}
});
Could you give some advice? Am I supposed to put the promises in the client view template instead?
This package adds a dependency on cosmos:browserify, which I assume is unnecessary (maybe even detrimental?) after Meteor 1.3. Should it be removed?
How are this version of meteor-promise and the okgrow version (https://github.com/okgrow/meteor-promise) related?
It appears that this version has been worked on more recently - it is preferred?
How to Synchronous call in server side (return result)
// Method
Meteor.methods({
demo({name}){
return name
}
})
-------
// Server call
const inServer = Meteor.callPromise('demo', { name: 'Theara' })
console.log('Result', inServer) // Don't work
I create the Meteor.method()
to generate reports, so I want to show the spinner
or any loading...
when the serve is running.
Could I check "is ready" to wait the result like pub/sub?
Please example for me.
DevTools failed to parse SourceMap: http://host:port/packages/deanius_promise/client/runAsync.browserify.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.