Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
activeperception opened this issue Jul 6, 2017 · 1 comment
Open

Comments

@activeperception
Copy link

activeperception commented Jul 6, 2017

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

@ansaries
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants