I have to implement a subscriptions list in node.js and currently have this object:
var SubReq = function(topic, address, port){
this.topic = topic,
this.address = address,
this.port = port
}
var Subscribers = [];
I also implemented functions to add subscriptors (using push) and delete subscriptors (using splice) from that list. The subscriptos should be UNIQUE (only one with same topic, address, and port) At the moment I'm using a very simple approach which consist on scanning the whole array to check if the new subscription exist already, and if it doesn't, I add it. Same with delete; I have to parse the whole array until I find the one to delete.
My question is if there is a better approach to create lists that are unique and more efficient to add/delete subscriptions?
I would appreciate any help. Thanks Gus