Can you run a meteor method while another is running?


#1

I have two buttons that fire off meteor methods.

{{#if isRunning}}
  {{>CylonButton method="Stop" text="Stop"}}
{{else}}
  {{>CylonButton method="Start" text="Start"}}
{{/if}}

These call a meteor method on the back end.

Meteor.methods({
  start: function () {
    Cylon.execute('wait', 10000);  // just as an example, waits for 10 seconds
  },
  stop: function () {
    Cylon.execute('stop');  // stops the current execution
    console.log('Stopped');
  }
});

It seems like you can’t press the stop button to fire off the stop method. Is there a way to fix this?


#2

You need to use this.unblock() in the method(s): http://docs.meteor.com/#/full/method_unblock


#3

Wouldn’t I have to unblock in my original start method? What if I didn’t want to do that?


#4

Yes.

I don’t know - why wouldn’t you?


#5

Because I want only that one stop method to be available, but all the other ones to still be blocked


#6

Ah, okay, I understand. That’s an interesting (and useful) requirement. Unfortunately, I don’t know of an easy way to address it - sorry. :disappointed:


#7

I think it can be handled more traditionally via WebApp.connectHandlers but that seems a little clunky