How to check ready() of ReactiveMethod.call() package in client template?


#1

I use ReactiveMethod.call() package, and I want to check ready() in my template

if(...ready()){
   return data;
}else{
   return 'Loading...';
}

#2

There is no ready test, it returns undefined when first run, followed by the actual call result when successful: https://github.com/stubailo/meteor-reactive-method/blob/master/reactive-method.js#L12-L18.

So, you should be able to do:

var result = ReactiveMethod.call('myMethod');
if ('undefined' === typeof result) {
  return 'Loading...';
} else {
  return result;
}