Skip to content

Commit

Permalink
Document the pause/resume API
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Apr 3, 2012
1 parent f957b62 commit 1aa8cdc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ feed.on('error', function(er) {
feed.follow();
```

<a name="pause"></a>
## Pause and Resume

A Follow feed is a Node.js stream. If you get lots of changes and processing them takes a while, use `.pause()` and `.resume()` as needed. Pausing guarantees that no new events will fire. Resuming guarantees you'll pick up where you left off.

```javascript
follow("https://example.iriscouch.com/boogie", function(error, change) {
var feed = this

if(change.seq == 1) {
console.log('Uh oh. The first change takes 30 hours to process. Better pause.')
feed.pause()
setTimeout(function() { feed.resume() }, 30 * 60 * 60 * 1000)
}

// ... 30 hours with no events ...

else
console.log('No need to pause for normal change: ' + change.id)
})
```

<a name="events"></a>
## Events

Expand Down

0 comments on commit 1aa8cdc

Please sign in to comment.