Meteor教程 - 未定义追踪器

时间:2018-05-23 07:11:13

标签: javascript ionic-framework meteor

我正在做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:自动运行时未定义跟踪器   (http://localhost:8100/build/vendor.js:178469:13)at   Observable._subscribe   (http://localhost:8100/build/vendor.js:178480:27)at   Observable._trySubscribe   (http://localhost:8100/build/vendor.js:23023:25)at   Observable.subscribe(http://localhost:8100/build/vendor.js:23011:93)   在http://localhost:8100/build/main.js:57:65在maybeReady   (http://localhost:8100/build/vendor.js:123856:57)at   HTMLDocument.loadingCompleted   (http://localhost:8100/build/vendor.js:123868:9)at t.invokeTask   (http://localhost:8100/build/polyfills.js:3:15660)在r.runTask   (http://localhost:8100/build/polyfills.js:3:10834)在e.invokeTask [as   调用](http://localhost:8100/build/polyfills.js:3:16794

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

2 个答案:

答案 0 :(得分:0)

我的猜测是订阅并不直接连接到自动运行。尝试将两者分开:

 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

答案 1 :(得分:0)

新节点安装解决了问题