Skip to content

Commit

Permalink
events section in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tcql committed Nov 20, 2015
1 parent 5c7a68d commit 431525c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,58 @@ tilereduce({
})
```

## Events

TileReduce returns an [EventEmitter]().

This comment has been minimized.

Copy link
@mourner

mourner Nov 20, 2015

Member

link?


### start

Fired once all workers are initialized and before the first tiles are sent for processing

```js
tilereduce({/* ... */})
.on('start', function () {
console.log('starting');
});
```

### map

Fired just before a tile is sent to a worker. Receives the tile and worker number assigned to process the tile.

```js
tilereduce({/* ... */})
.on('map', function (tile, workerId) {
console.log('about to process ' + JSON.stringify(tile) +' on worker '+workerId);
});
```

### reduce

Fired when a tile has finished processing. Receives data returned in the map function's `done` callback (if any), and the tile.

```js
var count = 0;
tilereduce({/* ... */})
.on('reduce', function (result, tile) {
console.log('got a count of ' + result + ' from ' + JSON.stringify(tile));
count++;
});
```

### end

Fired when all queued tiles have been processed. Use this event to output final reduce results.

```js
var count = 0;
tilereduce({/* ... */})
.on('end', function () {
console.log('Total count was: ' + count);
});
```


## Development

### Testing
Expand Down

0 comments on commit 431525c

Please sign in to comment.