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

Timesync.serverTime running each sec in nonReactive mode #20

Open
aashuagg opened this issue Jan 20, 2015 · 3 comments
Open

Timesync.serverTime running each sec in nonReactive mode #20

aashuagg opened this issue Jan 20, 2015 · 3 comments
Labels

Comments

@aashuagg
Copy link

I want to access server time on client side though only when queried for. So I have a function to get the current server time non-reactively:

getServerTime = function() {
    var serverTime;
    if (!TimeSync.isSynced()) {
        TimeSync.resync();
    } else {
        serverTime = Deps.nonreactive(function() {
            return TimeSync.serverTime();
        })
    }
    return serverTime;
}

It used to work fine in meteor 0.8.3 but now I have upgraded to meteor 1.0 and TimeSync.serverTime runs continuously causing my subscribes to run infinitely.

Does it need some change for meteor 1.0?

@mizzao
Copy link
Collaborator

mizzao commented Feb 11, 2015

I don't understand why your function is so convoluted. Why not just use

TimeSync.serverTime( Date.now() );

This way you reactively depend on whether the time is properly synced, but not the actual value that you're querying for.

@aashuagg
Copy link
Author

will this work with Meteor 0.8.3 as well?

On Wed, Feb 11, 2015 at 9:49 AM, Andrew Mao notifications@github.com
wrote:

I don't understand why your function is so convoluted. Why not just use

TimeSync.serverTime(new Date());

This way you reactively depend on whether the time is properly synced, but
not the actual value that you're querying for.


Reply to this email directly or view it on GitHub
#20 (comment)
.

@mizzao
Copy link
Collaborator

mizzao commented Feb 11, 2015

I don't know. I'm not sure which version of this package was the latest on 0.8.3. Why don't you just try it?

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

No branches or pull requests

2 participants