Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:00:00+00:00 2026-06-05T00:00:00+00:00

If I change a Session var and trigger a re-subscription via autosubscribe , is

  • 0

If I change a Session var and trigger a re-subscription via autosubscribe, is there any callback mechanism to wait until the ‘latest’ data is down from the server? [1]

If you take a look at this gist you’ll see some code that logs the content of a collection over time as the subscription changes. A relevant section of the output:

at Subscribed; comments are: first post on #1 - second post on #1 
at Flushed; comments are: first post on #1 - second post on #1 
at Subscription complete; comments are: first post on #1 - second post on #1 - first post on #2 - second post on #2

So, even after (a) calling .subscribe, (b) calling Meteor.flush (c) being inside the onReady callback for the .subscribe; there is still stale data in the collection, and only in the 3rd case is the ‘correct’ data in there.

I realise that reactive templates and .observe will eventually receive the correct data and things will ‘settle’ into the correct state. But is there some way we can tell that we aren’t there yet?

For instance, most of the meteor example apps (and my own apps) are prone to jerking around a bit (similar to a FOUC) while data is added + removed from a subscribed collection. If we could tell that a subscription was ‘loading’ we could do something about this.

[1] Obviously the data on the server is constantly changing, but as you’ll see in the gist, I can’t (without a timeout) find a point where it’s even correct. Thus my use of ‘valid’ in the question.

A very simple and common use case

Take the madewith app; when you first load it up it appears that there are no apps registered, until after the data comes down the wire and the apps suddenly appear.

The reason for this is that Meteor.subscribe has been called, but the data has not yet come down the wire. But there’s no easy way for the template to tell that the data is pending and that it should show a ‘loading’ template. In madewith they actually do something when the data has loaded, but this is a callback and thus breaks out of the normal meteor way of doing things (i.e. reactive coding).

It would be much nicer (IMO) to be able to write something like:

 {{unless apps_loaded}}{{> loading}}{{/unless}}

and

 Template.madewith.apps_loaded = function() { return !Apps.isComplete(); }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:00:02+00:00Added an answer on June 5, 2026 at 12:00 am

    Interesting question.

    The right place to be notified for new subscriptions is the onReady callback. Notice the logging that happens there always includes your new data. Checking at (a) and (b) aren’t useful, because there’s latency between calling subscribe and when all the data arrives from the server.

    The underlying problem is there’s no equivalent onRemove callback that runs once the data for a just-stopped subscription has been removed. Moreover, autosubscribe deliberately starts new subs before stopping old ones, to avoid flicker.

    What’s the real use case? Most of the time such a callback isn’t necessary, because templates can also restrict their queries to the data that should be in scope. In your example, the template helper that renders comments might query only for comments with the current post_id in the Session, so there’s no harm having extra comments in the database.
    Something like this:

    Template.post.comments = function () {
      return Comments.find({post_id: Session.get('post_id')});
    };
    

    That permits strategies more sophisticated that the generic autosubscribe function, like subscribing to comments for the last three posts the user has viewed. Or, subscribing to the first few comments for each post, and then separately subscribing to a post’s full set of comments only when that post is selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We need to change the session ID length generated by tomcat. By default it
List<Foo> fooList = Session[foo] as List<Foo>; fooList.Add(bar); Does the call to Add() change the
change() function works and detects changes on form elements, but is there a way
Right now i'm storing my session data in the memory store which comes bundled
Trying to play a sound via javascript and want to change it dynamically using
I'm using Spring.NET AOP to determine when a C# persistent object has change any
I'm trying to create a change password option on my site. I'm using session
I'm taking a pictures with a webcam via flash and posting the data to
In rails 2.3, I changed session store from cookies to active_record. I compared session.inspect
Drupal employs a custom session handler that changes the familiar...: $_SESSION['foo'] = 'bar'; echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.