Hello,
I have working code in angular for MERGE subscription. This is working fine in angular.
I have implemented this by using
this.subscription = new Subscription("MERGE", this.itemNames, this.fieldNames);
In this itemNames and fieldNames already I know so given statically, there is no issue on this.
In COMMAND subscription I have used this in using HTML it's working fine without any issue. But when I use in angular 2 this not working same which I have done in HTML.
I did below code in my javascript file when I use HTML,
var liverateGrid = new DynaGrid("lsliverates",true);
liverateGrid.setNodeTypes(["div","span","img","a"]);
liverateGrid.setAutoCleanBehavior(true,false);
liverateGrid.addListener({
onVisualUpdate: function(key,info) {
console.log(info);
if (info == null) {
return;
}
liverateGrid.setSort("order", false, true);
var liverateSubscription = new Subscription("COMMAND",liverateId,fieldList);
liverateSubscription.setDataAdapter(lsdata.provider);
liverateSubscription.setRequestedSnapshot("yes");
liverateSubscription.addListener(liverateGrid);
lsClient.subscribe(liverateSubscription);
And my template looks like,
<tbody>
<tr id="lsliverates" class="liverate-body" data-source="lightstreamer" >
<td><div data-source="lightstreamer" data-field="desc"></div></td>
<td class='table_data'><div data-source="lightstreamer" data-field="bid"></div></td>
<td class='table_data'><div data-source="lightstreamer" data-field="ask"></div></td>
<td class='table_data'><div data-source="lightstreamer" data-field="delivery"></div></td>
<td style="display:none;"><div data-source="lightstreamer" data-field="order"></div></td>
</tr>
</tbody>
But same I have tried in angular 2 for COMMAND mode, (For MERGE I know the itemNames and fieldNames list so that I have did this success by using the link (
https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-angular2)
This below code I have tried in angular but not working,
let lsData = JSON.parse(localStorage.getItem('WLLSData'));
this.lsClient = new LightstreamerClient("http://url:8080", lsData.adapter);
this.lsClient.connectionSharing.enableSharing("WLCommonConnection", "ATTACH", "CREATE");
this.lsClient.connectionOptions.setHttpExtraHeaders({ "username": lsData.username });
this.lsClient.connect();
this.dynasubscription = new Subscription("COMMAND", "lmxtrade" , this.dynafieldNames);
this.dynasubscription.setDataAdapter(lsData.provider);
this.dynasubscription.setRequestedSnapshot("yes");
var liverateGrid = new DynaGrid("liverates",true);
liverateGrid.setNodeTypes(["div","span","img","a"]);
liverateGrid.setAutoCleanBehavior(true,false);
liverateGrid.addListener({
onVisualUpdate: function(key, info, domNode) {
console.log(info);
},
onItemUpdate: (updateObject) => {
var itemName = updateObject.getItemName();
console.log(itemName);
}
});
console.log(liverateGrid);
this.lsClient.subscribe(this.dynasubscription);
Template looks like,
<div id="liverates" data-source="lightstreamer">
<div style="border-right: 1px solid rgb(27, 104, 94);" class="com-name" data-source="lightstreamer" data-field="desc"></div>
<div class="comm_bod" data-source="lightstreamer" data-field="bid"></div>
<div class="comm_bod" data-source="lightstreamer" data-field="ask" ></div>
</div>