Deps重新计算的Meteor和Iron-Router订阅异常:错误:成员已存在

时间:2013-11-28 12:06:14

标签: javascript node.js meteor iron-router

重要提示:我目前正在 SHARK 分支中使用Meteor和Iron-Router

为了解决问题,我想说我有两条路线:

// Home
this.route('home', {
    path: '/',
    layoutTemplate: 'layout',
    action: function() {
        // Performing some animation
    }
});

// User profile
this.route('profile', {
    path: '/profile/:id',
    controller: UserShowRouter
});

UserShowRouter看起来像这样:

UserShowRouter = RouteController.extend({

before: function() {
    this.subscribe('user', this.params.id).wait();
    this.subscribe('userPlaylists', this.params.id).wait();
},

data: function() {

    var user = Meteor.users.findOne({
            'profile.username': this.params.id
        }),

    var playlistsMade = Playlists.find({
            'user.id': user._id
    });

    return {
        user: user,
        playlistsMade: playlistsMade,
    };

},

action: function() {
    this.render('profile', {
        to: 'rightbarYield'
    });
}

});

user有几个playlists。在用户的个人资料页面上,应显示用户数据和他拥有的播放列表。

在before hook中,我订阅了用户和用户拥有的所有播放列表。以下是相应的发布功能:

Meteor.publish('user', function(username) {
    return Meteor.users.find({
        'profile.username': username
     });
});

Meteor.publish('userPlaylists', function(username) {
    return Playlists.find({
        'user.username': username
    });
});

出现以下问题:当我第一次访问/profile/user页面时,一切都像魅力一样。当我从/profile/user页面更改为/(主页)页面然后返回到/profile/user后,抛出异常:

Exception from Deps recompute: Error: Member already exists: jzJMYRTYjG9FDqHmT
  at _extend.add (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:1757:17)
  at Object.ObserveSequence.observe.addedAt (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:3572:15)
  at Object.diffFn.addedBefore (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:196:17)
  at http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:2649:42
  at Array.forEach (native)
  at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?13ab483e8a3c795d9991577e65e811cd0b827997:130:11)
  at LocalCollection._diffQueryOrderedChanges (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:2639:5)
  at diffArray (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:194:3)
  at http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:125:11
  at Object._.extend.nonreactive (http://localhost:3000/packages/deps.js?34f4906d0a01d1c2873bed712b3bd039da3c9bab:341:14) 

当我在main.js(不在路由控制器中)Meteor.subscribe('playlists') <订阅所有播放列表时,不会发生 < / p>

但是这带来了以下问题:当我不再在profile/user路由时,而是在家庭路由器/并且其中一个现有播放列表的数据发生变化(例如标题)更改)并在抛出异常后重新计算依赖项:

Exception in queued task: TypeError: Cannot read property 'data' of null
  at Object.ObserveSequence.observe.changed (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:3584:52)
  at Object.cursor.observe.changed (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:137:25)
  at Object.cursor.observeChanges.changed (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:1096:19)
  at http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:349:15
  at _.extend.runTask (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:558:11)
  at _.extend.flush (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:586:10)
  at _.extend.drain (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:594:12)
  at LocalCollection.update (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:638:22)
  at Object.self._connection.registerStore.update (http://localhost:3000/packages/mongo-livedata.js?2f66d8591aa3225badaf5a98bfba28287bff3a3d:239:30)
  at Object.store.(anonymous function) [as update] (http://localhost:3000/packages/livedata.js?dab0057c9e7c90bcd874be39d89b9cd54637979b:3583:48)

我不知道问题出在哪里 - 与流星一起?与铁路由器?我的订阅或路线? 非常感谢任何帮助!谢谢

0 个答案:

没有答案