title: Meteor, One to Many Relationship & add field only to client side collection in Publish?
body: <p>Can anyone see what may be wrong in this code, basically I want to check if a post has been shared by the current logged in user AND add a temporary field to the client side collection: isCurrentUserShared.</p>
  
  <p>This works the 1st time when loading a new page and populating from existing Shares, or when adding OR removing a record to the Shares  collection ONLY the very 1st time once the page is loaded. </p>
  
  <p>1) isSharedByMe only changes state 1 time, then the callbacks still get called as per console.log, but isSharedByMe doesn't get updated in Posts collection after the 1st time I add or remove a record. It works the 1st time.</p>
  
  <p>2) Why do the callbacks get called twice in a row, i.e. adding 1 record to Sharescollection triggers 2 calls, as show by console.log.</p>
  
  <pre><code>Meteor.publish('posts', function() {
  
      var self = this;
      var mySharedHandle;
  
  
      function checkSharedBy(IN_postId) {
          mySharedHandle = Shares.find( { postId: IN_postId, userId: self.userId }).observeChanges({
  
              added: function(id) {
                  console.log("   ...INSIDE checkSharedBy(); ADDED: IN_postId = " + IN_postId );
                  self.added('posts', IN_postId, { isSharedByMe: true });
              },
  
              removed: function(id) {
                  console.log("   ...INSIDE checkSharedBy(); REMOVED: IN_postId = " + IN_postId );
                  self.changed('posts', IN_postId, { isSharedByMe: false });
              }
          });
      }
  
  
      var handle = Posts.find().observeChanges({
  
          added: function(id, fields) {
              checkSharedBy(id);
              self.added('posts', id, fields);
          },
  
          // This callback never gets run, even when checkSharedBy() changes field isSharedByMe.
          changed: function(id, fields) {
              self.changed('posts', id, fields);
          },
  
          removed: function(id) {
              self.removed('posts', id);
          }
      });
  
      // Stop observing cursor when client unsubscribes
      self.onStop(function() {
          handle.stop();
          mySharedHandle.stop();
      });
  
      self.ready();
  });
  </code></pre>