Variable Syncing Problem

48 views
Skip to first unread message

Andy Luong

unread,
Apr 22, 2012, 11:06:20 AM4/22/12
to nowjs
I am trying to change the value of a variable from the server side. It
seems like when I print the value of the client's variable on the
server, the value is changing. However, the client doesn't get the
change. Creating new variables seems to sync fine, but overwriting
existing data doesn't seem to sync to the client.

Here is a link to my two pieces of a code: server.js and index.html

http://www.notey.it/n/ZHc

I found a work around of making a function on the client to change the
value, but it seems to defeat variable syncing if I do that.

-Andy

Nate Morse

unread,
Apr 23, 2012, 1:50:59 PM4/23/12
to no...@googlegroups.com
Actually I have noticed that, the very first server-side assignment to
now.test does synchronize out to the client, but then after that, a
second (3rd, ...) assignment does *not* sync.
I have also worked around this with function calls etc.


--
--Nate

N. Morse

unread,
Apr 23, 2012, 1:56:53 PM4/23/12
to no...@googlegroups.com
BTW, I am running... node v0.6.2 and ...
├─┬ n...@0.7.6
│ ├── node-...@0.5.2
│ └─┬ sock...@0.9.6

Filipe Deschamps

unread,
Apr 23, 2012, 8:41:46 PM4/23/12
to nowjs
"Sync values using remote function calls rather than using synced
variables. As described above, some amount of traversal is required to
synchronize variables in the now namespace. If you need to rapidly set
a value on one client and then immediately use that value on the other
clients, consider broadcasting this using function calls. Function
calls are much faster than using variable syncing."

http://nowjs.com/bestpractices

On Apr 23, 2:50 pm, Nate Morse <morse.n...@gmail.com> wrote:
> Actually I have noticed that, the very first server-side assignment to
> now.test does synchronize out to the client, but then after that, a
> second (3rd, ...) assignment does *not* sync.
> I have also worked around this with function calls etc.
>

Andy Luong

unread,
Apr 23, 2012, 9:09:21 PM4/23/12
to nowjs
I agree that makes sense. However, I don't think the values are ever
getting overwritten. I tried waiting 5 seconds, and it seems to not be
synced.

N. Morse

unread,
Apr 24, 2012, 9:11:05 AM4/24/12
to no...@googlegroups.com
I also agree that functions are more useful, and that the whole
syncing of data with no events associated with updates is a bad idea.
Syncing should be either augmented to include update notification
events or the whole feature should be removed.
Meanwhile there is definitely a bug.

--
Nate Morse
Programmer
SmartCatalog
217 Commercial Street, Suite 406
Portland, ME 04101
800 770-8425
207 774-4769
207 780-0129 fax
www.academiccatalog.com

Reply all
Reply to author
Forward
0 new messages