Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining server side #7

Closed
pociej opened this issue Jul 10, 2015 · 3 comments
Closed

Chaining server side #7

pociej opened this issue Jul 10, 2015 · 3 comments

Comments

@pociej
Copy link

pociej commented Jul 10, 2015

Hi @chicagogrooves , idea is nice but it doesnt work server side because of Meteor.bindEnvironment.
Lets try your example server side :

Meteor.promise("createCustomer", "foo@bar.com", "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.

@deanrad
Copy link
Owner

deanrad commented Jul 10, 2015

Hmm, I know I set the package up to be client and server, but I wonder if I should reconsider that now.

The reason being - it's strange to make a method call from the server side, the approach described here shows how to maintain a method that can be called directly - without Meteor.call, or Meteor.promise.
http://stackoverflow.com/questions/23188424/meteorjs-meteor-methods-call-from-server-to-server

What do you think- if you want to try to support your use case from the server, let me know a bit more, maybe create a failing test in a PR ?

@pociej
Copy link
Author

pociej commented Jul 17, 2015

@deanius , yep i know that it is strange to call methods from server to server (anyway in tutorial , you called 'inspiration' they calling methods server side ;) ) , but it is detail.
You can easy change you package and call server side defined functions instead of methods, youwill have same problem , Imo meteor needs own implementation of server side promises .
In regards to the cleint side usage of package it is also strange , calling meteor methods one after another generates unnecessary client-server ping pong . In most cases you want to call one method which chain few tasks server side and wait for response . But to do that you need server side implementation of promises ( or use other tool ).

@deanrad
Copy link
Owner

deanrad commented Jul 17, 2015

Meteor's support for ES6 (including Promises, I assume), in version 1.2 may make this package obsolete- we'll see what they come up with.. Thanks for your very valid points!

@deanrad deanrad closed this as completed Jul 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants