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 9136291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:56:01+00:00 2026-06-17T08:56:01+00:00

How do I use a client side reconnection event in Meteor. On the client,

  • 0

How do I use a client side reconnection event in Meteor.

On the client, Meteor.apply takes a new wait option, which ensures
that no further method calls are sent to the server until this method
is finished; it is used for login and logout methods in order to keep
the user ID well-defined. You can also specifiy an onReconnect handler
which is run when re-establishing a connection; Meteor Accounts uses
this to log back in on reconnect.

Can someone provide an example.

Here’s the example in the accounts package.

  Accounts._makeClientLoggedIn = function(userId, token) {
    Accounts._storeLoginToken(userId, token);
    Meteor.default_connection.setUserId(userId);
    Meteor.default_connection.onReconnect = function() {
      Meteor.apply('login', [{resume: token}], {wait: true}, function(error, result) {
        if (error) {
          Accounts._makeClientLoggedOut();
          throw error;
        } else {
          // nothing to do
        }
      });
    };
    userLoadedListeners.invalidateAll();
    if (currentUserSubscriptionData) {
      currentUserSubscriptionData.handle.stop();
    }
    var data = currentUserSubscriptionData = {loaded: false};
    data.handle = Meteor.subscribe(
      "meteor.currentUser", function () {
        // Important! We use "data" here, not "currentUserSubscriptionData", so
        // that if we log out and in again before this subscription is ready, we
        // don't make currentUserSubscriptionData look ready just because this
        // older iteration of subscribing is ready.
        data.loaded = true;
        userLoadedListeners.invalidateAll();
      });
  };

I assume you can’t just define another default_connection.onReconnect if you want the accounts one to still work?

Thanks.

Edit:

Thinking about it a bit more, instead of using onReconnect are you perhaps supposed to use Meteor.status() instead?

  • 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-17T08:56:02+00:00Added an answer on June 17, 2026 at 8:56 am

    Harry, I saw your comment above and made this change. I think you are correct. Because Meteor.status is a reactive variable, this will re-run anytime the connection status changes.

    if (Meteor.isClient) {
        Tracker.autorun(function () {
            if (Meteor.status().connected) {
                console.log("connected");
            } else {
                console.log("disconnected");
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use the new client side validation features of asp.net MVC
I have an issue when trying to optimize client scripts that use client-side jade
I'm trying to configure a web application that can use client-side JavaScript for localization
I'm trying to use MVC2 client-side validation in a partial view that is rendered
I have a string that I use for client side validation: private const String
I have Results page that contains an signup form. I'm trying to use client-side
I'm using xval to use client side validation in my asp.net mvc2 web-application. Despite
I am looking for sample code or documentation on how to use client side
Are there are any rules for when to use Client-Side validation and when to
I have JavaScript application, where I use client-side templates (underscore.js, Backbone.js). Data for initial

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.