Prevent memory leaks.

This commit is contained in:
Michael Teeuw 2016-04-05 14:54:40 +02:00
parent 5420314784
commit 6ff3a37665

View File

@ -17,6 +17,17 @@ var NewsFetcher = function() {
self.items = [];
/* fetchNews()
* Fetch the new news items.
*
* attribute url string - The url to fetch.
* attribute success function(items) - Callback on succes.
* attribute error function(error) - Callback on error.
*/
self.fetchNews = function(url, success, error, encoding) {
self.successCallback = success;
self.errorCallback = error;
var parser = new FeedMe();
parser.on('item', function(item) {
@ -34,18 +45,6 @@ var NewsFetcher = function() {
self.errorCallback(error);
});
/* public methods */
/* fetchNews()
* Fetch the new news items.
*
* attribute url string - The url to fetch.
* attribute success function(items) - Callback on succes.
* attribute error function(error) - Callback on error.
*/
self.fetchNews = function(url, success, error, encoding) {
self.successCallback = success;
self.errorCallback = error;
request({uri:url, encoding:null}).pipe(iconv.decodeStream(encoding)).pipe(parser);
};
};