Publications blocking my app


#1

Hello everyone,

I’m currently experimenting with meteor as a backend for my app.
I have a subscription with 100 Datasets without any queries so far that I have to keep track of.

Each time I start my app, first the publication starts running to store the subscribed data and I can’t use my app while its loading.
Is it possible to start the subscription asynchronously or somehow that I can still use my app, while the data is loading?


#2

Subscriptions are asynchronous. They become “ready” at some time after they are called.

You can start the publications asychronously, but you will still end up waiting on the client. However, defining a publication is not the same as subscribing to it.

Meteor.setTimeout(() => {
  Meteor.publish(...);
}, 0);

Do you really need to subscribe to 100 “datasets” (do you mean collections) simultaneously? All that data has to be sent to the client.


#3

Hey Rob,

thanks for the answer.

What I’m trying to accomplish is that I want to store the data from the publications in an offline storage on my phone. The reason I’m not using a meteor method for that is because I want to keep track of all the changes, while I’m still online.

I’m open for alternatives though


#4

If you are just trying to allow offline use, then any data in the subscription when the device goes offline is there and usable / editable while offline as long as the user doesn’t refresh the browser. This most likely has limits of course based on OS and browser, but, once the app reconnects to the backend, it will sync the changes it has to the database.

That said, I’ve only done this in development mode, and only by myself. I can’t verify if the changes from multiple users will sync properly, or overwrite other user’s changes regardless of timestamp, so that would be something to check.

Maybe that’s not what you’re trying to accomplish. But, if it is, and you don’t need all of that data to be offline, I would really suggest limiting the subscription of the data through what you publish (basically set a filter on your publication so as not to publish alllll of it if possible).

For example, I have a field on an app where my user starts to type an address. My address collection has 100,000’s of addresses in it, but I take the characters as they type and feed that data to my publication which then publishes only 20 potential matches to what’s been typed so far. This makes the page load much faster, and makes the app far more responsive.

This wouldn’t work great for offline use however, because I never know which of the addresses they may need, but I allow them to free-type an address if needed.