title: Meteor.logout() causes helper to rerun
body: <p>I want to add a logout button to my application but that turns out to be more difficult than I thought because there's a situation in which a helper is called unexpectedly after calling <code>Meteor.logout</code>. Consider the following simple application (<a href="http://meteorpad.com/pad/4GSMMxRvHDNK3k5Fw" rel="nofollow">you can find the complete code in this MeteorPad</a>; I tried to keep it as short as possible):</p>
  
  <p>The server publishes the contents of a <code>Tasks</code> collection if the user is logged in. Otherwise, it publishes no records.</p>
  
  <pre><code>Meteor.publish('tasks', function() {
    if (this.userId) {
      return Tasks.find();
    } else {
      return null;
    }
  });
  </code></pre>
  
  <p>There's a layout template that handles the login/logout, subscribes to the publication, and displays a sub template (<code>task</code>):</p>
  
  <pre><code>&lt;template name="layout"&gt;
    {{#if loggedInAndReady}}
      {{&gt; task}}
  
      &lt;button class="logout"&gt;Logout&lt;/button&gt;
    {{else}}
      &lt;button class="login"&gt;Login&lt;/button&gt;
    {{/if}}
  &lt;/template&gt;
  </code></pre>
  
  <p>Inside this <code>task</code> template, there is a helper <code>title</code> that retrieves a task from the subscription using <code>Tasks.findOne()</code> and writes to the log when it's called:</p>
  
  <pre><code>&lt;template name="task"&gt;
    {{description}}
  &lt;/template&gt;
  
  Template.task.helpers({
    title: function() {
      console.log("task helper");
      Tasks.findOne();
    }
  });
  </code></pre>
  
  <hr>
  
  <p><strong>Here is the problem:</strong> <em>When I log out, <code>loggedInAndReady</code> will become false but the <code>title</code> helper of the <code>task</code> template is still called.</em> However, I don't want the helper to be called, because I made the assumption that the data I'm trying to get in my helpers always exits. This assumption is always true, except for the short moment between the logout and the removal of the template.</p>
  
  <p>These are the steps that happen when you log in and out again (you can see this output in the development console of the MeteorPad linked above):</p>
  
  <pre><code>task template created
  task helper
  logging out
  task helper &lt;-- Why is this called? I'm already logged out.
  task template destroyed
  </code></pre>
  
  <p>I know that when the user is logged out, the <code>tasks</code> publication on the server is executed again with <code>null</code> as the new user ID, which, in turn, causes the helper on the client to run again because the result set changed (i.e., became empty). However, it's already known at this point that the result of the helper won't be used anymore (the template is destroyed afterwards).</p>
  
  <p>The strange thing is that when you log in, <em>reload the page</em>, and then log out, it works as expected (the helper is not called again):</p>
  
  <pre><code>task template created
  task helper
  logging out
  task template destroyed
  </code></pre>
  
  <p><strong>Am I misunderstanding a part of Meteor's reactivity concept or is there a mistake in the code? How can a page reload affect the execution of a helper like this?</strong></p>