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

Could I check "is ready" to wait the result like pub/sub? #8

Closed
thearabbit opened this issue Aug 1, 2015 · 6 comments
Closed

Could I check "is ready" to wait the result like pub/sub? #8

thearabbit opened this issue Aug 1, 2015 · 6 comments
Labels

Comments

@thearabbit
Copy link

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.

@deanrad
Copy link
Owner

deanrad commented Aug 1, 2015

Interesting point - could you show me more code ? If you're using the PromiseHelper, I just pushed an update that lets you pass an additional loading text, in addition to the function to wrap. If that's not your use case, I'm not sure I can help - post some code and let's see though :)

Template.foo.helpers({
  report: PromiseHelper(function(){ return Meteor.call(method, args); }, "loading...")
});

@thearabbit
Copy link
Author

// Server
Meteor.methods({
    add: function () {
        Meteor._sleepForMs(1000);
        return 'Welcome to Promise Call';
    }

// Client
<template name="myTpl">
   {{#if myValue}}
      {{myValue}}
   {{else}}
      {{> spinner}}
   {{/if}}

Template.myTpl.helpers({
   myValue: PromiseHelper(function(){
      return Meteor.call('add');
   })
})
</template>

@thearabbit
Copy link
Author

Could I use loading with spinner template?
PromiseHelper(function(){ return Meteor.call(method, args); }, Template.spinner)

@deanrad
Copy link
Owner

deanrad commented Aug 2, 2015

I think you could do so like this: Blaze.toHTML(Template.spinner)

Template.myTpl.helpers({
   myValue: PromiseHelper(function(){
      return Meteor.call('add');
   }, Blaze.toHTML(Template.spinner))
})

Let me know if that works for you - I'm not sure if that functionality is something I'd take on internally, but I'd document it as a valid use case if it works!

@thearabbit
Copy link
Author

It don't work. It show [object object].

@deanrad
Copy link
Owner

deanrad commented Sep 23, 2015

Sorry, I could not reproduce this - if you have a more full example I'd love to see it. Thanks for all the great questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants