add all as an event emitter
This commit is contained in:
parent
57d00504f4
commit
fadd256aa8
4 changed files with 68 additions and 6 deletions
23
readme.md
23
readme.md
|
@ -27,14 +27,33 @@ randomPuppy()
|
|||
|
||||
## API
|
||||
|
||||
### randomPuppy()
|
||||
### `randomPuppy()`
|
||||
|
||||
Returns a `promise` for a random puppy image url from http://imgur.com/ from https://www.reddit.com/r/puppy
|
||||
|
||||
### randomPuppy(subreddit)
|
||||
### `randomPuppy(subreddit)`
|
||||
|
||||
Returns a `promise` for a random image url from the selected subreddit. *Warning: We cannot promise it will be a image of a puppy!*
|
||||
|
||||
### `randomPuppy.all(subreddit)`
|
||||
|
||||
Returns an `eventemitter` for getting all random images for a subreddit.
|
||||
|
||||
```js
|
||||
const event = randomPuppy.all(subreddit);
|
||||
event.on('data', url => console.log(url));
|
||||
```
|
||||
|
||||
Or:
|
||||
```js
|
||||
const event = randomPuppy.all('puppies');
|
||||
|
||||
Observable.fromEvent(event, 'data')
|
||||
.subscribe(data => {
|
||||
console.log(data);
|
||||
});
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
* Node 4 or newer.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue