Thanks. I'll look into that further. I have all this working nicely and in the final optimization steps of the code. So:
1. Given we get a subscription object via
let subscription = new Subscription(subscriptionMode, items, fields)
is there a way to do a reverse look up to get a subscription based on a given item? I.e.:
let subscription = new GetSubscription (item)
(see NOTE 1 below for my solution)
2. Similarly, if I RE-subscribe to the same EXACT 'items' array above do I get the same subscription reference or a new one?
The reason for this, as always, is decoupling. In this case, I've already decoupled various modules of the app to use the same Client instance (vertical decoupling) and if no CLIENT exists to create their own.
Similarly, I'm also decoupling the UI components inside the module to not be concerned with their stream or subscription source (in this case Lightstreamer and Subscription) which is 'horizontal decoupling' within the module. The most the UI components know about is a string (we internally call a 'topic') where a separate decoupled service can construct an 'item' from that 'topic' to pass to a
let subscription = new Subscription(subscriptionMode, createItem('topic'), fields).
Similarly when the UI component is destroyed it will unsubscribe('topic') as its last act--it knows nothing of Clients or Subscriptions or Lightstreamer and only knows the 'topic' string. I ideally do not want to manage my own Map<topic, subscription> internally OR pass the subscription handle or any other LS artifacts to the UI components.
NOTE 1: Given the documentation, reverse look-up can be done by the following psuedocode;
let subscriptions = _lightstreamerClient.getSubscriptions()
for (subscription in subscriptions) {
let items = subscription.getItems()
for (item in items) {
if item.includes('topic') exit both loops with found subscription object...
}
}
NOTE 2: For your reference, I'm managing that decoupled service using an NgRx state machine.
Thanks.