Urigo / meteor-rxjs

Exposing Mongo Cursor as RxJS Observable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscription readiness - how to call ready() in autorun?

activeperception opened this issue · comments

Hi,

To run arbitrary code when a subscription changes I've always used the snippet at readiness ?

It leverages the fact that "ready()" is a reactive data source.

How do I achieve the same with meteor-rxjs ?

Thanks,
Raffaele

        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');
        });