socket-function 0.8.17 → 0.8.18

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.
@@ -34,9 +34,9 @@ export function promiseToObservable<T>(promise: Promise<T>): { value: T | undefi
34
34
  };
35
35
  }
36
36
 
37
- export function asyncObservable<Output, Key>(maxCount: number, getValue: (key: Key) => Promise<Output>): {
38
- (key: Key): Output | undefined;
39
- invalidate(key: Key): void;
37
+ export function asyncObservable<Output, Args extends any[]>(maxCount: number, getValue: (...args: Args) => Promise<Output>): {
38
+ (...args: Args): Output | undefined;
39
+ invalidate(...args: Args): void;
40
40
  invalidateAll(): void;
41
41
  } {
42
42
  let invalidateAllSeqNum = observable({ seqNum: 1 }, undefined, { deep: false, proxy: false });
@@ -46,8 +46,8 @@ export function asyncObservable<Output, Key>(maxCount: number, getValue: (key: K
46
46
  seqNum: { value: number };
47
47
  }>();
48
48
 
49
- get["invalidate"] = (key: Key) => {
50
- let hash = JSON.stringify(key);
49
+ get["invalidate"] = (...args: Args) => {
50
+ let hash = JSON.stringify(args);
51
51
  let value = values.get(hash);
52
52
  if (!value) return;
53
53
  values.delete(hash);
@@ -59,9 +59,9 @@ export function asyncObservable<Output, Key>(maxCount: number, getValue: (key: K
59
59
  values.clear();
60
60
  invalidateAllSeqNum.seqNum++;
61
61
  };
62
- function get(key: Key) {
62
+ function get(...args: Args) {
63
63
 
64
- let hash = JSON.stringify(key);
64
+ let hash = JSON.stringify(args);
65
65
  let value = values.get(hash);
66
66
  if (!value) {
67
67
 
@@ -79,7 +79,7 @@ export function asyncObservable<Output, Key>(maxCount: number, getValue: (key: K
79
79
  }
80
80
 
81
81
  // We call inside another function so that synchronous errors still get wrapped in the observable
82
- let valueObs = promiseToObservable((async () => getValue(key))());
82
+ let valueObs = promiseToObservable((async () => getValue(...args))());
83
83
  value = {
84
84
  valueObs,
85
85
  seqNum: observable({ value: 1 }, undefined, { deep: false, proxy: false }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.8.17",
3
+ "version": "0.8.18",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {