@ndriadev/futurable 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +15 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -40,6 +40,7 @@
40
40
  - [Futurable.allSettled](#futurableallsettledvalues-t-signal-abortsignal)
41
41
  - [Futurable.any](#futurableanyvalues-t-signal-abortsignal)
42
42
  - [Futurable.race](#futurableracevalues-t-signal-abortsignal)
43
+ - [Futurable.polling](#futurablepollingvalue--futurable--interval-signal-interval-number-signal-abortsignal)
43
44
  - [ToDo](#TODO)
44
45
  - [License](#License)
45
46
 
@@ -134,6 +135,7 @@ They are the following:
134
135
  - [Futurable.allSettled](#futurableallsettledvalues-t-signal-abortsignal)
135
136
  - [Futurable.any](#futurableanyvalues-t-signal-abortsignal)
136
137
  - [Futurable.race](#futurableracevalues-t-signal-abortsignal)
138
+ - [Futurable.polling](#futurablepollingvalue--futurable--interval-signal-interval-number-signal-abortsignal)
137
139
 
138
140
  ### constructor(executor: FuturableExecutor<T>, signal?: AbortSignal)
139
141
  Futurable is instantiable like a classic Promise.
@@ -587,6 +589,19 @@ const f = Futurable.race([
587
589
  f.cancel();
588
590
  ```
589
591
 
592
+ ### Futurable.polling<T>(value: ()=> Futurable<T>, { interval, signal }:{interval: number, signal?: AbortSignal})
593
+ Creates a polling service with cancellation support and possibility to handle error.
594
+
595
+ *Example*
596
+ ```javascript
597
+ //...code
598
+ const polling = Futurable.polling(() => Futurable.fetch(/*...*/)), {interval: 1000});
599
+ polling.catch(err => console.error(err));
600
+
601
+ //...code
602
+
603
+ polling.cancel();
604
+ ```
590
605
 
591
606
  # ToDo
592
607
  - Think about the possibility of making a static method that returns an object with the futurable, resolve, reject, utils properties inside to be used as done for usePromiser.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ndriadev/futurable",
3
3
  "description": "Extension Javascript's Promise API with more functionalities",
4
4
  "private": false,
5
- "version": "2.1.0",
5
+ "version": "2.1.1",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist/",