3 ms·
For example, usinging XHR model: file = new File.Reader() file.onReady = printfile file.onError = showerror file.onProgress = showprogress file
by Kilimanjaro 17y ago
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')