Skip to content
Prev Previous commit
Next Next commit
Add #### prefix to Event: 'close' and backticks to 'close' similar to…
… stream.Readable event: 'close' section
  • Loading branch information
Jenna Vuong committed May 1, 2016
commit 827dfcbf8dd3ceb7d38c64be220248922c0ae43c
4 changes: 2 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ Examples of writable streams include:
* [child process stdin][]
* [`process.stdout`][], [`process.stderr`][]

Event: 'close'
#### Event: 'close'

Emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed. The event indicates that no more events will be emitted, and no further computation will occur.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this differs from 'end'?
Should a user expect 'close' or 'end' to proceed? Which one happens first?

I will also move this block after 'end', meaning that 'end' is the preferred way of waiting for the end of a stream.

Copy link
Copy Markdown
Contributor Author

@jennabelle jennabelle May 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcollina

I hesitate to move the 'Event: 'close'' block to after the 'Event: 'end'' block because these events seem to be in alphabetical order for better user experience.

The difference between 'close' and 'end' events:

  1. 'close' event - Whatever it is tied to, for example a stream, it is done now. This event comes from the fs.close() method and is optional. Not all streams emit this event.
  2. 'end' event - Waits for the current data to finish buffering. means no more data will be emitted. This event is tied to the end() function on Streams.


Not all streams will emit the 'close' event.
Not all streams will emit the `'close'` event.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will say this is an optional event for implementors.


#### Event: 'drain'

Expand Down