Skip to content

Files

Latest commit

df54c83 · Aug 23, 2015

History

History

ex-async-stream

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Aug 23, 2015
Aug 23, 2015
Aug 23, 2015

readme.md

The Async Stream Problem

See "How can I asynchronously assign a stream after one has already been created?"

The Solution

We will develop a function called makeRequest that returns a Duplexify stream. At the same time we make the stream, we make a request to get an authorization token.

Expectations

The function will return a stream that performs as a normal request stream would, except we are able to make an async API request in front of it without even noticing.

Try It

# Start the server (if it's not running already)
$ cd stream-faqs
$ npm install
$ npm start

# Run the example
$ cd ex-async-assign
$ npm install
$ node .