Skip to content

Commit

Permalink
Return streams immediately if no callback is provided (#152)
Browse files Browse the repository at this point in the history
Since the stream is available right away we can return it.
  • Loading branch information
reconbot committed May 14, 2016
1 parent 1794be1 commit d64ab23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -118,6 +118,16 @@ client.post('statuses/update', {status: 'I Love Twitter'}, function(error, twee
Using the `stream` convenience method, you to open and manipulate data via a stream piped directly from one of the streaming API's. Let's see who is talking about javascript:

```javascript
var stream = client.stream('statuses/filter', {track: 'javascript'});
stream.on('data', function(tweet) {
console.log(tweet.text);
});

stream.on('error', function(error) {
throw error;
});

// You can also get the stream in a callback if you prefer.
client.stream('statuses/filter', {track: 'javascript'}, function(stream) {
stream.on('data', function(tweet) {
console.log(tweet.text);
Expand Down
3 changes: 3 additions & 0 deletions lib/twitter.js
Expand Up @@ -246,6 +246,9 @@ Twitter.prototype.stream = function(method, params, callback) {
if ( typeof callback === 'function' ) {
callback(stream);
}
else {
return stream;
}
};


Expand Down

0 comments on commit d64ab23

Please sign in to comment.