Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ffc4311

Browse files
Update example about reading value from configuration file.
1 parent 35aa38d commit ffc4311

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

‎workers/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
url : http://www.w3schools.com/xml/cd_catalog.xml

‎workers/controllers/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ exports.install = function() {
44

55
function view_index() {
66
var self = this;
7-
self.json(F.global.weather);
7+
self.json(F.global.xml);
88
}

‎workers/definitions/weather.js renamed to ‎workers/definitions/worker.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
function refresh() {
22
// workers/weather.js will runs in other process
3-
var worker = F.worker('weather', 'current', 5000);
3+
var worker = F.worker('xml', 'current', 5000);
44

55
// worker === http://nodejs.org/api/child_process.html#child_process_class_childprocess
66
worker.on('message', function(obj) {
7-
// console.log(obj);
8-
framework.global.weather = obj;
7+
F.global.xml = obj;
98
});
109
}
1110

‎workers/workers/weather.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎workers/workers/xml.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require('total.js');
2+
3+
// Loads the framework without HTTP server
4+
F.load('debug', ['config'], '../');
5+
6+
U.download(CONFIG('url'), ['get'], function(err, response) {
7+
8+
var data = [];
9+
10+
response.on('data', U.streamer('<CD>', '</CD>', function(item) {
11+
data.push(item.parseXML());
12+
}));
13+
14+
response.on('end', function() {
15+
process.send(data);
16+
process.exit();
17+
});
18+
19+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /