mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Prevent memory leaks.
This commit is contained in:
parent
5420314784
commit
6ff3a37665
@ -17,6 +17,17 @@ var NewsFetcher = function() {
|
|||||||
|
|
||||||
self.items = [];
|
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();
|
var parser = new FeedMe();
|
||||||
|
|
||||||
parser.on('item', function(item) {
|
parser.on('item', function(item) {
|
||||||
@ -34,18 +45,6 @@ var NewsFetcher = function() {
|
|||||||
self.errorCallback(error);
|
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);
|
request({uri:url, encoding:null}).pipe(iconv.decodeStream(encoding)).pipe(parser);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user