triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

How to use socket.io through all pages of a NS app #18

Closed demym closed 6 years ago

demym commented 8 years ago

Hi,

i have successfully implemented nativescript + socket.io chat.

Problem is that my app has several pages (and one of them is the chat interface). How can i catch socket.io events in any page, and then propagate this event to the other pages ? Typically, i would like that if a user receives a chat msg while he is not on the chat page, that msg would be dispatched to the chat page (or at least have some notification about it).

Thanks very much in advance. I am using plain JS and NativeScript

mubbashar commented 8 years ago

@demym can you please share you code if possible. I am using socket.io with nativescript 2.3.0 and not able to configured it

narender56 commented 7 years ago

Hi @demym ,

Can you please tell me how to integrate nativescript with socket io ,i'm trying to implement chat app with nativescript-chatview ,if you could help that would be so obliged.thanks in advance and wish you a happy new year

viniciodeltoro commented 7 years ago

I would recommend to create an Angular service to handle all socket connection with the server and then broadcast all data through your components/services by using rxjs Observables. The good thing is that Angular uses it and it's one more node_module that comes by default in all nativescript apps so you don't have to install anything, just use it.

triniwiz commented 6 years ago

You can check the angular demo for and example