@cripty2001/utils 0.0.144 → 0.0.145

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.
@@ -30,8 +30,9 @@ export declare function useWhispr<T>(data: T | Whispr<T>): Whispr<T>;
30
30
  * Subscribe a callback to a Whispr inside a react component, properly handling unsubscription on unmount.
31
31
  * @param w The whispr to subscribe to
32
32
  * @param cb The callback to call on value change
33
+ * @param unsafe If true, the callback will be allowed to throw errors, that will then bubble up
33
34
  */
34
- export declare function useOnWhispr<T>(w: Whispr<T>, cb: (value: T) => void): void;
35
+ export declare function useOnWhispr<T>(w: Whispr<T>, unsafe: boolean | undefined, cb: (value: T) => void): void;
35
36
  /**
36
37
  * Return a reactive current timestamp (ms), updated at the given interval.
37
38
  * @returns The current timestamp
@@ -66,10 +66,11 @@ function useWhispr(data) {
66
66
  * Subscribe a callback to a Whispr inside a react component, properly handling unsubscription on unmount.
67
67
  * @param w The whispr to subscribe to
68
68
  * @param cb The callback to call on value change
69
+ * @param unsafe If true, the callback will be allowed to throw errors, that will then bubble up
69
70
  */
70
- function useOnWhispr(w, cb) {
71
+ function useOnWhispr(w, unsafe = false, cb) {
71
72
  (0, react_1.useEffect)(() => {
72
- const unsub = w.subscribe(cb);
73
+ const unsub = w.subscribe(cb, undefined, unsafe);
73
74
  return () => unsub();
74
75
  }, [w, cb]);
75
76
  }
@@ -205,7 +206,7 @@ function useAsync(f, data, debouce = 200) {
205
206
  */
206
207
  function useAsyncEffect(f, data, debounce = 200) {
207
208
  const dispatcher = useAsync(f, data, debounce);
208
- useOnWhispr(dispatcher.data, (data) => {
209
+ useOnWhispr(dispatcher.data, true, (data) => {
209
210
  if (!data.loading && !data.ok) {
210
211
  throw data.error;
211
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.144",
3
+ "version": "0.0.145",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@cripty2001/whispr": "^0.2.1",
25
+ "@cripty2001/whispr": "^0.2.3",
26
26
  "lodash": "^4.17.21"
27
27
  },
28
28
  "devDependencies": {