News for hackers. Stuff that matters.
Re:Node.js guys discussing async programming style by Kilimanjaro on Sunday February 21, 2010 @09:23AM (#1140577)
For example, usinging XHR model:

  file = new File.Reader()
  file.onReady    = printfile
  file.onError    = showerror
  file.onProgress = showprogress
  file.read('myfile.txt')
Not restricted to callback and errback only, more events may be available according to the process being executed, keeping JS as natural as possible.

Hacks can be added on top to handle parallel or chainable process.

One last thing, make the process asynchronous by default and set a property to false to make it synchronous, no need to force a last parameter to a function.

  file.async = false
  file.read('myfile.txt')

There are no comments on this comment yet.