From 855880617d928cc1ed114658f1e66d53884632fb Mon Sep 17 00:00:00 2001 From: Amaury Date: Sun, 18 Apr 2021 18:14:47 +0200 Subject: [PATCH] update readme --- README.md | 44 ++++++++++++++++---------------------------- package.json | 2 +- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index caa1dfe..5a3a77f 100644 --- a/README.md +++ b/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. diff --git a/package.json b/package.json index 234b69d..ff3d2e0 100644 --- a/package.json +++ b/package.json @@ -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",