Meteor-Community-Packages / meteor-timesync

NTP-style time synchronization between server and client, and facilities to use server time reactively in Meteor applications.
https://packosphere.com/mizzao/timesync
MIT License
118 stars 36 forks source link

TimeSync.serverTime documentation issue #4

Closed wI2L closed 10 years ago

wI2L commented 10 years ago

Hi.

I have noticed an error in the doc. For TimeSync.serverTime(clientTime) it says: returns the server time for a given client time. A reactive variable. If clientTime is not omitted, returns the current time on the server which reactively updates every second.

I first tried to pass Date.now() to get a reactive return (i'm using the function in an helper), but it didnt reactively update.

When i remove Date.now() and called TimeSync.serverTime() it worked. Also, after checking the source, i've read : if (!clientTime) timeTick.depend().

Regards,

William

mizzao commented 10 years ago

Hi @wI2L,

Sorry, that's a typo in the doc, it should say

If clientTime is omitted ...

It's reactive if you don't pass in a client time, and will show the server's current time. Otherwise, it shows the server time for whatever client time was passed in, and this depends only on the computed offset, not the current time.

Does that make sense?

wI2L commented 10 years ago

I arrived to this conclusion after i looked in the source code indeed. I just wanted to point out the error in the doc, which leaded me to this problem.

Anyway, thanks for your answer and the precisions.

mizzao commented 10 years ago

What do you mean by 'the precisions'?

wI2L commented 10 years ago

Sorry, i meant your explanations :)

mizzao commented 10 years ago

Ah, right. My French is a bit rusty.