update readme
This commit is contained in:
parent
ac12992c60
commit
855880617d
44
README.md
44
README.md
|
@ -13,12 +13,12 @@ An example :
|
|||
const ListenerModule = require("ListenerRSS");
|
||||
const ListenerRss = ListenerModule.ListenerRss;
|
||||
|
||||
const listener = new ListenerRss("my-test-service", "fake.rss.service");
|
||||
const listener = new ListenerRss({
|
||||
address: "fake.rss.service"
|
||||
});
|
||||
|
||||
// make a request to the adr 'fake.rss.service'
|
||||
myListener.fetchRSS().then((obj, err) => {
|
||||
// some act
|
||||
});
|
||||
const feed = await myListener.fetchRSS();
|
||||
```
|
||||
|
||||
## Recurrent usage
|
||||
|
@ -30,17 +30,14 @@ An example :
|
|||
const ListenerModule = require("ListenerRSS");
|
||||
const ListenerRss = ListenerModule.ListenerRss;
|
||||
|
||||
const listener = new ListenerRss("my-test-service", "fake.rss.service", 5 * 60);
|
||||
const listener = new ListenerRss({
|
||||
address: "fake.rss.service"
|
||||
});
|
||||
|
||||
const callback_fun_update = (obj) => {
|
||||
// some act
|
||||
};
|
||||
const callback_fun_new_entries = (obj) => {
|
||||
// some act
|
||||
};
|
||||
listener.on("update", feed => { /* ... */ });
|
||||
listener.on("error", err => { /* ... */ });
|
||||
listener.on("newEntries", feedEntries => { /* ... */ });
|
||||
|
||||
listener.on("update", callback_fun);
|
||||
listener.on("newEntries", callback_fun);
|
||||
|
||||
listener.start();
|
||||
|
||||
|
@ -87,7 +84,7 @@ Reject the promise if the server can't be resolved.
|
|||
### start()
|
||||
|
||||
This function will call the `update` event to each success update, the
|
||||
`update_err` event to each fail update, and the `newEntries` event for
|
||||
`error` event to each fail update, and the `newEntries` event for
|
||||
each update who contains a new item.
|
||||
|
||||
#### Events
|
||||
|
@ -95,30 +92,21 @@ each update who contains a new item.
|
|||
Each event take one arg into the callback function.
|
||||
|
||||
```js
|
||||
const callback_fun = (obj) => {
|
||||
// some act
|
||||
};
|
||||
const callback_fun_err = (err) => {
|
||||
// some act
|
||||
};
|
||||
const callback_fun_new_entries = (newEntries) => {
|
||||
// some act
|
||||
};
|
||||
listener.on("update", feed => { /* ... */ });
|
||||
listener.on("error", err => { /* ... */ });
|
||||
listener.on("newEntries", feedEntries => { /* ... */ });
|
||||
|
||||
listener.on("update", callback_fun);
|
||||
listener.on("update_err", callback_fun_err);
|
||||
listener.on("new_entries", callback_fun_new_entries);
|
||||
```
|
||||
|
||||
#### update
|
||||
|
||||
It used a callback who receive the received object entirely inside an object.
|
||||
|
||||
#### update_err
|
||||
#### error
|
||||
|
||||
It used a callback who receive an error object.
|
||||
|
||||
#### new_entries
|
||||
#### newEntries
|
||||
|
||||
It used a callback who receive only new entries inside an array.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "listener-rss",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"description": "A lightweight library to create a listener from a rss feed.",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
|
|
Loading…
Reference in New Issue
Block a user