On ready (for connection) and on disconnection

78 views
Skip to first unread message

Filipe Deschamps

unread,
Jun 20, 2012, 6:48:17 PM6/20/12
to nowjs
Hi guys!

I'm loving NowJS. Look what I've done so far: http://www.insidernews.com.br/mobile

Over 3G, there's a lag until NowJS is downloaded, connected and ready
to use. Is there anyway to identify this? Just like jQuery $
(document).ready

And if connection is lost, is there anyway to detect?

Best regards!

Filipe

Filipe Deschamps

unread,
Jun 20, 2012, 11:22:59 PM6/20/12
to nowjs
now.core.socketio.on('disconnect', function()
{
// Disconnected
});

now.core.socketio.on('connect', function()
{
// Connected
});

It work 100%!!!

Ian Serlin

unread,
Jun 21, 2012, 3:11:39 AM6/21/12
to no...@googlegroups.com
Hey Filipe!

Glad you're loving NowJS and you found an answer. :)

Just wondering, did you try using now.ready(function(){....}) inside of a document ready function and did that work?

Filipe Deschamps

unread,
Jun 21, 2012, 6:37:00 PM6/21/12
to nowjs
Hi Ian! How are you?

No, I didn't try to use now.ready() since I wanted to keep functions
with the same reading, like "if disconnected do this, if connected do
this". Since I'm noob at coding, reading the code like that makes more
sense to me.

And it's already live, it's amazing for me that I could accomplish
what I wanted :) if is disconnected, the color of the UI changes, but
once connected, it changes again: http://www.insidernews.com.br/mobile

What I'm trying to find now is how to control socket.io parameters
while using nowjs. I need to increase heart beat to keep checking more
quickly a disconnection and a reconnection. Is taking too long for my
application to respond to this changes in environment.

Best regards,

Filipe

Ian Serlin

unread,
Jun 21, 2012, 6:41:28 PM6/21/12
to no...@googlegroups.com
Hey Filipe,

Take a look at http://nowjs.org/doc/symbols/nowjs#.initialize, you can pass the socketio parameters if you use now.initialize().

You might also want to check out Flotype's Bridge at some point: http://www.flotype.com/ which is their next version on nowjs, but it won't be completely free forever.

HTH,

Filipe Deschamps

unread,
Jun 24, 2012, 4:51:05 PM6/24/12
to nowjs
Thanks Ian, cool tip about socket.io parameters, I'm giving this a try
right now :)

And about Bridge, really nice project!!! But now I'm a little bit
worried: will they keep giving NowJS enough attention, or should I
just use socket.io? I'm worried if Node.js or socket.io receives a
major update and it breaks NowJS.

Best regards!

Ian Serlin

unread,
Jun 25, 2012, 1:48:53 PM6/25/12
to no...@googlegroups.com
Hi Filipe,

I don't know officially, but I think that Bridge is their way forward. NowJS is open source so it's conceivable the community could continue to develop the technology but if you're worried about that and think you'll have a long-lived project I would get to know socket.io or SockJS https://github.com/sockjs/sockjs-client .

Filipe Deschamps

unread,
Jun 26, 2012, 8:46:44 PM6/26/12
to nowjs
Ian, thank you mate.

I think I've made de decision: adapt all my code do socket.io :(

Since I will not be able to help with the project itself, I will need
to be in the hands of the most future proof one.

Best regards!

* But I will keep my eyes here :)

On 25 jun, 14:48, Ian Serlin <i...@ianserlin.com> wrote:
> Hi Filipe,
>
> I don't know officially, but I think that Bridge is their way forward.
> NowJS is open source so it's conceivable the community could continue to
> develop the technology but if you're worried about that and think you'll
> have a long-lived project I would get to know socket.io or SockJShttps://github.com/sockjs/sockjs-client.
>
> Ian Serlin
>
> i...@ianserlin.comhttp://useful.iohttp://www.linkedin.com/in/ianserlin
Reply all
Reply to author
Forward
0 new messages