Reputation: 2247
I'm wondering what's the best approach to do the following: I have a Polymer-element
(PubNub
(which handled Realtime Messaging
)) which is "instantiated" with a some attribute values (the elements properties (more precisely, which channel to listen to/join)). And since the user should be able to switch chat rooms (/channels), I'm not sure if it's such a great idea to "instantiate" 5 PubNub-elements
and in turn have 5 active chats going on in the background (receiving messages), if nothing else it would drain more battery power(?).
So, should I instantiate one PubNub-element
and then remove and replace it when a user swaps channel? And how is this done best in Polymer
?
Or is there some other approach one should take when dealing with this kind of problem?
Upvotes: 3
Views: 113
Reputation: 593
You are right, the current pubnub-element is very basic and lacks many functionalities, as you have already noticed.
As Craig said, I don't generally recommend to create a bunch of instances either, however, the polymer element lacks the way you can modify all properties on the fly- you may be able to change the channel name as publishing, but it doesn't work the way for subscribing...
Instead of making some workaround using Polymer elements, I suggest to just use our vanilla JavaScript APIs. It maybe so much easier for your scenario.
And please do not hesitate to send us a pull requests or two :-)
Upvotes: 1