首页 文章

Meteor教程 - 未定义跟踪器

提问于
浏览
1

我正在做Meteor Ionic教程,在纠正了几个错误后,我完全陷入了困境 .

用这个改变我的main.ts代码

import 'meteor-client';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { MeteorObservable } from 'meteor-rxjs'; 
import { Meteor } from 'meteor/meteor'; 
import { AppModule } from './app.module';

Meteor.startup(() => {   
    const subscription = MeteorObservable.autorun().subscribe(() => {

        if (Meteor.loggingIn()) {
            return;
        }

        setTimeout(() => subscription.unsubscribe());
        platformBrowserDynamic().bootstrapModule(AppModule);   
    }); 
});

抛出下一个错误

ReferenceError:在Observable._subscribe(http:// localhost:8100 / build / vendor.js:178480:27)的自动运行(http:// localhost:8100 / build / vendor.js:178469:13)中未定义跟踪器 . )at Observable._trySubscribe(http:// localhost:8100 / build / vendor.js:23023:25)在Observable.subscribe(http:// localhost:8100 / build / vendor.js:23011:93)的http: //localhost:8100/build/main.js:57:65在maybeDady(http:// localhost:8100 / build / vendor.js:123856:57)的HTMLDocument.loadingCompleted(http:// localhost:8100 / build) /tndor.js:123868:9)at t.invokeTask(http:// localhost:8100 / build / polyfills.js:3:15660)at r.runTask(http:// localhost:8100 / build / polyfills.js) :3:10834)在e.invokeTask [as invoke](http:// localhost:8100 / build / polyfills.js:3:16794)

我检查了所有依赖项,一切正常

2 回答

  • 0

    我的猜测是订阅与autorun没有直接关联 . 尝试将两者分开:

    const sub = MeteorObservable.subscribe('mySubscriptionForSomeData');
        const autorun = MeteorObservable.autorun();
        Observable.merge(sub, autorun).subscribe(() => {
            this.jobs = SomeCollection.find().zone(); // Data is ready here
        }, (err) => {
            console.log(err); // error fetching data
        }, () => {
            console.log('This will print always, whether data is fetched or err happened');
        });
    

    资料来源:https://github.com/Urigo/meteor-rxjs/issues/98

  • 0

    新节点安装解决了这个问题

相关问题