Iโm completely a noob, so maybe itโs not very good, and he wastes resources, but I still donโt know how to check it, so I will drop it here and hope that some of the masters would tell us OK or is it wrong, and most importantly, why ?.
The way is to put a tw.stream call inside a function and call that function with an array of words that you want to track. It will start tracking new words and stop tracking deleted words:
// Array to store the tracked words var TwitWords = []; // Tracker function function TrackWords(array){ tw.stream('statuses/filter',{track:array},function(stream){ stream.on('data',function(data){ console.log(data.text); }); }); } // Add word function AddTwitWord(word){ if(TwitWords.indexOf(word)==-1){ TwitWords.push(word); TrackWords(TwitWords); } } // Remove word function RemoveTwitWord(word){ if(TwitWords.indexOf(word)!=-1){ TwitWords.splice(TwitWords.indexOf(word),1); TrackWords(TwitWords); } }
I hope that everything is in order, because this is the only way I found.
source share