流星发布的 this.ready 不会触发

Meteor publication's this.ready doesn't trigger

我将我的两篇出版物合二为一,因为它们非常相似。他们都return编辑了一组游标。我在低级别重写了它们 API,以便对数据删除进行一些控制。

我的问题是,出于我完全忽略的原因,订阅 onReady 回调从未被触发。我的应用程序中还有其他低级 pubsub,它们以类似的方式发布数据并且运行良好。

在服务器上,我所有的日志都正确显示,没有显示错误。发布正确运行,数据有效发送到客户端。 客户端触发onReadyonError回调none

出版:

Meteor.publish("getTalkthread", function ( thread_id ) {
  unblock(this);

    console.log("start");

  let uids = tags = corrections = [],
            self = this;

    let posts_cursor = Modules.both.queryGet({
                type                : 'posts',
                method          : 'find',
                query               : { $or: [
                            { _id: thread_id },
                            { parent: thread_id }
                          ]
                        },
                projection  : { sort    : { _id: 1 },
                                                limit   : 50
                                            }
            });

  let posts_array = posts_cursor.fetch(),
      posts_ids = posts_array.map( e => ( e._id ) );

    //console.log("fetched posts", posts_array);

  let corrs_cursor = Modules.both.queryGet({
                type                : 'corrections',
                method          : 'find',
                query               : { talkId: { $in: posts_ids } },
                projection  : { sort    : { _id: 1 },
                                                limit   : 50
                                            }
            });

  let corrs_array = corrs_cursor.fetch();

    //console.log("fetched corrs", corrs_array);

  let posts_authors = posts_array.map( e => ( e.owner ) ),
      corrs_authors = corrs_array.map( e => ( e.owner ) );

  let users_ids = _.union( posts_authors, corrs_authors );

  let users_cursor = Modules.both.queryGet({
            type                : 'users',
            method          : 'find',
            query               : { _id: { $in: users_ids } },
            projection  : { sort        : { date: -1 },
                            limit       : 100,
                            fields  : USER_PROFILE_FIELDS_
                        }
        });

    //console.log("fetched users", users_cursor.fetch());

  let observers = {};

  observers.posts = posts_cursor.observeChanges({
        added       : ( id, fields )    => { console.log("post added " + id); self.added  ("posts", id, fields); },
        changed : ( id, fields )    => { console.log("post changed " + id); self.changed("posts", id, fields);  },
        removed : ( id )                    => {
            console.log("test");
      if ( id != thread_id ) {
                console.log(true);
        self.removed("posts removed " + id);
      }
    }
    });

    observers.users = users_cursor.observeChanges({
        added       : ( id, fields )    => { console.log("user added " + id); self.added  ("users", id, fields);    },
        changed : ( id, fields )    => { console.log("user changed " + id); },
        removed : ( id )                    => { console.log("user removed " + id); }
    });

  observers.corrs = corrs_cursor.observeChanges({
        added       : ( id, fields )    => { console.log("corr added " + id); self.added  ("corrections", id, fields);  },
        changed : ( id, fields )    => { console.log("corr changed " + id); self.changed("corrections", id, fields);    },
        removed : ( id )                    => { console.log("corr removed " + id); self.removed("corrections", id);                }
    });

    console.log("observers created");

    this.ready();

  self.onStop( () => {
        observers.posts.stop();
        observers.users.stop();
        observers.corrs.stop();
    });

    console.log("end");

});

订阅:

      console.log("sub");
      self.subscribe("getTalkthread", id, self.rerun.get()), {
        onReady: function () {
          console.log("READY");
          if ( !Posts.findOne({ _id: id } )) {
            $("#404NotFound").show();
            $("#isoContent").hide();
          } else if ( Posts.findOne( id ) ) {
            $("#isoContent").show();
          }
          $("#spin").hide();
        },
        onError: function () {
          console.log("ERROR");
          $("#spin").hide();
          $("#404NotFound").show();
          $("#isoContent").hide();
        }
      };

客户端页面正确呈现,但未触发DOM操作,禁止显示内容。有人看到我在这里做错了什么吗?

谢谢你

编辑:

我试过return三个游标的数​​组,不管什么原因,问题都是一样的。但是,我不明白为什么。

虽然我不明白为什么,但使用 Arunoda 的 SubsManager 而不是本机 Meteor.subscribe 解决了问题。