This is a "Hello World" application, using a view that inherits from a Readable stream.
To invoke, the following command begins listening on localhost:3000.
node app.js
To see results:
http://localhost:3000
- The main function of app.js instantiates a "View" from the view.js file.
- The View overrides the Readable's _read() function with an empty function.
- The View also overrides the Readable's render() function to do the following:
- Immediately push out the text for the <head> of the page
- Yield to a function that will ultimately (in the next tick) return the "Hello World" text. The render() function pauses at that point.
- When that function returns, render() resumes, and assigns the return value to the
body
variable - Push out the returned text wrapped in <body> tags
- Push out the closing </html> tag and
- Close the connection with push(null)