Working with callbacks in Javascript
[cc lang=”javascript”]
feedRead.parseUrl (urlTestFeed, timeOutSecs, function (err, theFeed) {
if (err) {
console.log (err.message);
}
else {
console.log (“It took ” + utils.secondsSince (whenstart) + ” seconds to read and parse the feed.”);
console.log (“theFeed.head == ” + utils.jsonStringify (theFeed.head));
console.log (“theFeed.items [0] == ” + utils.jsonStringify (theFeed.items [0]));
for (var i = 0; i < theFeed.items.length; i++) {
console.log (“Item #” + utils.padWithZeros (i, 2) + “: ” + theFeed.items [i].title + “.”);
}
}
});
[/cc]
After some experimenting, I figured out that all I needed in the feedRead.parseUrl call was the function name (with no parameters, even though it had parameters), and then the function could be factored out:
[cc lang=”javascript”]
feedRead.parseUrl (urlTestFeed, timeOutSecs, myparser);
function myparser (err, theFeed) {
if (err) {
console.log (err.message);
}
else {
console.log (“It took ” + utils.secondsSince (whenstart) + ” seconds to read and parse the feed.”);
console.log (“theFeed.head == ” + utils.jsonStringify (theFeed.head));
console.log (“theFeed.items [0] == ” + utils.jsonStringify (theFeed.items [0]));
for (var i = 0; i < theFeed.items.length; i++) {
console.log (“Item #” + utils.padWithZeros (i, 2) + “: ” + theFeed.items [i].title + “.”);
}
}
}
[/cc]
Note that the function does not have a semicolon at the end, but the call to feedRead.parseUrl does…
References:
https://codeburst.io/javascript-what-the-heck-is-a-callback-aba4da2deced
https://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
Getting some traction on micro.blog
Wither the history of podcasting?
I hope that Dr. Bottomley will document his research in this area (seems like he is working on a book). However, I am more interested in finding good podcasts to listen to, and playing around with creating podcasts myself. As Dave Winer has pointed out, creating and distributing podcasts is an open platform – anyone can do it. People can disagree on “who was first” or “what is a podcast”, but I want to focus on the practitioners, the people who are creating podcasts, no matter what the topic.
Knowledge wiki examples
The effect of music in our lives
Stars and Stripes Forever – It’s the law!
See this article for more background. Also, the Marine Band website has free downloads of Sousa march recordings – neat!
Three tips for satisfying the users of your products
- Make users happy with your product as quick as you can
- Help your users as much as you can after that
- The simplest way to create value online is to save the user time
How embedded software projects run into trouble
- Unrealistic schedules
- Quality gets lip service
- Poor resource planning
- Writing optimistic code
- Weak managers or team leads
- Crummy analog/digital interfacing
- Bad science
- The undisciplined use of C and C++
- Jumping into coding too quickly
- Not enough resources allocated to a project