valdres 0.2.0-alpha.74 → 0.2.0-alpha.75

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 (33) hide show
  1. package/dist/index.js +23 -19
  2. package/dist/types/src/atomFamily.d.ts +2 -3
  3. package/dist/types/src/indexConstructor.d.ts +1 -2
  4. package/dist/types/src/lib/atomFamilyAtom.d.ts +3 -3
  5. package/dist/types/src/lib/createAtomFamily.d.ts +1 -1
  6. package/dist/types/src/lib/createGlobalAtomFamily.d.ts +3 -4
  7. package/dist/types/src/lib/getState.d.ts +3 -3
  8. package/dist/types/src/lib/initAtom.d.ts +1 -1
  9. package/dist/types/src/lib/stringifyFamilyArgs.d.ts +1 -0
  10. package/dist/types/src/lib/updateStateSubscribers.d.ts +1 -1
  11. package/dist/types/src/selector.d.ts +1 -1
  12. package/dist/types/src/selectorFamily.d.ts +2 -2
  13. package/dist/types/src/types/AtomFamily.d.ts +6 -7
  14. package/dist/types/src/types/AtomFamilyAtom.d.ts +3 -3
  15. package/dist/types/src/types/AtomFamilyDefaultValue.d.ts +2 -2
  16. package/dist/types/src/types/AtomFamilyGlobalAtom.d.ts +1 -1
  17. package/dist/types/src/types/AtomFamilySelector.d.ts +3 -3
  18. package/dist/types/src/types/EqualFunc.d.ts +1 -1
  19. package/dist/types/src/types/Family.d.ts +1 -1
  20. package/dist/types/src/types/GetValue.d.ts +3 -3
  21. package/dist/types/src/types/Selector.d.ts +4 -4
  22. package/dist/types/src/types/SelectorFamily.d.ts +3 -4
  23. package/dist/types/src/types/SelectorOptions.d.ts +1 -1
  24. package/dist/types/src/types/State.d.ts +1 -1
  25. package/dist/types/src/types/Store.d.ts +2 -2
  26. package/dist/types/src/types/SubscribeFn.d.ts +2 -2
  27. package/dist/types/src/utils/isAtomFamily.d.ts +1 -1
  28. package/dist/types/src/utils/isFamily.d.ts +1 -1
  29. package/dist/types/src/utils/isFamilyAtom.d.ts +1 -1
  30. package/dist/types/src/utils/isFamilySelector.d.ts +1 -1
  31. package/dist/types/src/utils/isFamilyState.d.ts +1 -1
  32. package/dist/types/src/utils/isSelectorFamily.d.ts +1 -1
  33. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ var updateStateSubscribers = (state, data) => {
113
113
  const familySubscriptions = data.subscriptions.get(state.family);
114
114
  if (familySubscriptions?.size) {
115
115
  for (const subscribtion of familySubscriptions) {
116
- subscribtion.callback(state.familyKey);
116
+ subscribtion.callback(...state.familyKey);
117
117
  }
118
118
  }
119
119
  }
@@ -422,8 +422,7 @@ var updateSelectorSubscribers = (selector, data) => {
422
422
  const newValue = initSelector(selector, data);
423
423
  if (selector.equal(newValue, oldValue))
424
424
  return;
425
- } catch (e) {
426
- }
425
+ } catch (e) {}
427
426
  }
428
427
  if (subscribtions?.size) {
429
428
  for (const subscribtion of subscribtions) {
@@ -432,7 +431,7 @@ var updateSelectorSubscribers = (selector, data) => {
432
431
  }
433
432
  if (familySubscriptions?.size) {
434
433
  for (const subscribtion of familySubscriptions) {
435
- subscribtion.callback(selector.familyKey);
434
+ subscribtion.callback(...selector.familyKey);
436
435
  }
437
436
  }
438
437
  };
@@ -1014,6 +1013,11 @@ var stableStringify = (x) => {
1014
1013
  return stableStringifyRecurse(x);
1015
1014
  };
1016
1015
 
1016
+ // src/lib/stringifyFamilyArgs.ts
1017
+ var stringifyFamilyArgs = (...args) => {
1018
+ return args.length === 1 ? stableStringify(args[0]) : stableStringify(args);
1019
+ };
1020
+
1017
1021
  // src/lib/createAtomFamily.ts
1018
1022
  var createOptions = (options = {}, family, familyKey, keyStringified) => {
1019
1023
  if (options.name) {
@@ -1028,27 +1032,27 @@ var createOptions = (options = {}, family, familyKey, keyStringified) => {
1028
1032
  return { equal, ...options, family, familyKey };
1029
1033
  }
1030
1034
  };
1031
- var handleDefaultValue = (defaultValue, key) => {
1035
+ var handleDefaultValue = (defaultValue, ...args) => {
1032
1036
  if (isSelectorFamily(defaultValue))
1033
- return defaultValue(key);
1037
+ return defaultValue(...args);
1034
1038
  if (typeof defaultValue === "function")
1035
- return () => defaultValue(key);
1039
+ return () => defaultValue(...args);
1036
1040
  return defaultValue;
1037
1041
  };
1038
1042
  var createAtomFamily = (defaultValue, options) => {
1039
1043
  const map = new Map;
1040
1044
  const keysAtom = atom(new Set);
1041
- const atomFamily = Object.assign((key) => {
1042
- const keyStringified = stableStringify(key);
1045
+ const atomFamily = Object.assign((...args) => {
1046
+ const keyStringified = stringifyFamilyArgs(...args);
1043
1047
  if (map.has(keyStringified)) {
1044
1048
  return map.get(keyStringified);
1045
1049
  }
1046
- const familyAtom = atomFamilyAtom(handleDefaultValue(defaultValue, key), createOptions(options, atomFamily, Object.freeze(key), keyStringified));
1050
+ const familyAtom = atomFamilyAtom(handleDefaultValue(defaultValue, ...args), createOptions(options, atomFamily, args, keyStringified));
1047
1051
  map.set(keyStringified, familyAtom);
1048
1052
  return familyAtom;
1049
1053
  }, {
1050
1054
  __valdresAtomFamilyMap: map,
1051
- release: (key) => map.delete(key),
1055
+ release: (...args) => map.delete(stringifyFamilyArgs(...args)),
1052
1056
  __keysAtom: keysAtom,
1053
1057
  __keysSelector: selector((get) => Array.from(get(keysAtom)))
1054
1058
  });
@@ -1104,11 +1108,11 @@ var index = (family, callback) => {
1104
1108
  return map.get(termKey);
1105
1109
  const itemSelectorMap = new Map;
1106
1110
  const selectorMapIndex = selector((get) => {
1107
- const ids = get(family);
1108
- ids.forEach((id) => {
1109
- if (itemSelectorMap.has(id))
1111
+ const array = get(family);
1112
+ array.forEach((args) => {
1113
+ if (itemSelectorMap.has(args))
1110
1114
  return;
1111
- itemSelectorMap.set(id, selector((get2) => callback(get2(family(id)), term)));
1115
+ itemSelectorMap.set(args, selector((get2) => callback(get2(family(...args)), term)));
1112
1116
  });
1113
1117
  return itemSelectorMap;
1114
1118
  });
@@ -1140,13 +1144,13 @@ var createOptions2 = (options = {}, family, familyKey, keyStringified) => {
1140
1144
  return { equal, ...options, family, familyKey };
1141
1145
  }
1142
1146
  };
1143
- var selectorFamily = (get, options) => {
1147
+ var selectorFamily = (callback, options) => {
1144
1148
  const map = new Map;
1145
- const selectorFamily2 = (key) => {
1146
- const keyStringified = stableStringify(key);
1149
+ const selectorFamily2 = (...args) => {
1150
+ const keyStringified = stringifyFamilyArgs(args);
1147
1151
  if (map.has(keyStringified))
1148
1152
  return map.get(keyStringified);
1149
- const newSelector = selector((selectorArgs) => get(key)(selectorArgs), createOptions2(options, selectorFamily2, key, keyStringified));
1153
+ const newSelector = selector((selectorArgs) => callback(...args)(selectorArgs), createOptions2(options, selectorFamily2, args, keyStringified));
1150
1154
  map.set(keyStringified, newSelector);
1151
1155
  return newSelector;
1152
1156
  };
@@ -1,4 +1,3 @@
1
- import type { AtomOptions } from "./types/AtomOptions";
2
- import type { FamilyKey } from "./types/FamilyKey";
3
1
  import type { AtomFamilyDefaultValue } from "./types/AtomFamilyDefaultValue";
4
- export declare function atomFamily<Key = FamilyKey, Value = unknown>(defaultValue?: AtomFamilyDefaultValue<Key, Value>, options?: AtomOptions<Value>): import(".").AtomFamily<Key, Value>;
2
+ import type { AtomOptions } from "./types/AtomOptions";
3
+ export declare function atomFamily<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(defaultValue?: AtomFamilyDefaultValue<Value, Args>, options?: AtomOptions<Value>): import(".").AtomFamily<Value, Args>;
@@ -1,4 +1,3 @@
1
1
  import type { AtomFamily } from "./types/AtomFamily";
2
- import type { FamilyKey } from "./types/FamilyKey";
3
2
  import type { Selector } from "./types/Selector";
4
- export declare const index: <T, K extends FamilyKey = FamilyKey, V = unknown>(family: AtomFamily<K, V>, callback: (value: V, term: T) => boolean) => ((term: T) => Selector<T[]>);
3
+ export declare const index: <Term, Value extends unknown, FamilyArgs extends [any, ...any[]] = [any, ...any[]]>(family: AtomFamily<Value, FamilyArgs>, callback: (value: Value, term: Term) => boolean) => ((term: Term) => Selector<Term[]>);
@@ -2,7 +2,7 @@ import type { AtomDefaultValue } from "../types/AtomDefaultValue";
2
2
  import type { AtomFamilyAtom } from "../types/AtomFamilyAtom";
3
3
  import type { AtomFamilyGlobalAtom } from "../types/AtomFamilyGlobalAtom";
4
4
  import type { AtomOptions } from "../types/AtomOptions";
5
- export declare function atomFamilyAtom<Key, Value>(defaultValue: AtomDefaultValue<Value>, options: AtomOptions<Value> & {
5
+ export declare function atomFamilyAtom<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(defaultValue: AtomDefaultValue<Value>, options: AtomOptions<Value> & {
6
6
  global: true;
7
- }): AtomFamilyGlobalAtom<Key, Value>;
8
- export declare function atomFamilyAtom<Key, Value>(defaultValue: AtomDefaultValue<Value>, options: AtomOptions<Value>): AtomFamilyAtom<Key, Value>;
7
+ }): AtomFamilyGlobalAtom<Value, Args>;
8
+ export declare function atomFamilyAtom<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(defaultValue: AtomDefaultValue<Value>, options: AtomOptions<Value>): AtomFamilyAtom<Value, Args>;
@@ -1,4 +1,4 @@
1
1
  import type { AtomFamily } from "../types/AtomFamily";
2
2
  import type { AtomFamilyDefaultValue } from "../types/AtomFamilyDefaultValue";
3
3
  import type { AtomOptions } from "../types/AtomOptions";
4
- export declare const createAtomFamily: <Key, Value>(defaultValue: AtomFamilyDefaultValue<Key, Value>, options?: AtomOptions<Value>) => AtomFamily<Key, Value>;
4
+ export declare const createAtomFamily: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(defaultValue: AtomFamilyDefaultValue<Value, Args>, options?: AtomOptions<Value>) => AtomFamily<Value, Args>;
@@ -1,5 +1,4 @@
1
- import type { AtomOptions } from "../types/AtomOptions";
2
- import type { FamilyKey } from "../types/FamilyKey";
3
- import type { AtomFamilyDefaultValue } from "../types/AtomFamilyDefaultValue";
4
1
  import type { AtomFamily } from "../types/AtomFamily";
5
- export declare const createGlobalAtomFamily: <Key = FamilyKey, Value = unknown>(defaultValue: AtomFamilyDefaultValue<Key, Value>, options: AtomOptions<Value>) => AtomFamily<Key, Value>;
2
+ import type { AtomFamilyDefaultValue } from "../types/AtomFamilyDefaultValue";
3
+ import type { AtomOptions } from "../types/AtomOptions";
4
+ export declare const createGlobalAtomFamily: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(defaultValue: AtomFamilyDefaultValue<Value, Args>, options: AtomOptions<Value>) => AtomFamily<Value, Args>;
@@ -2,6 +2,6 @@ import type { Atom } from "../types/Atom";
2
2
  import type { AtomFamily } from "../types/AtomFamily";
3
3
  import type { Selector } from "../types/Selector";
4
4
  import type { StoreData } from "../types/StoreData";
5
- export declare function getState<V, K>(atom: Atom<V>, data: StoreData, circularDependencySet?: WeakSet<Selector>): V;
6
- export declare function getState<V, K>(selector: Selector<V>, data: StoreData, circularDependencySet?: WeakSet<Selector>): V;
7
- export declare function getState<V, K>(family: AtomFamily<V, K>, data: StoreData, circularDependencySet?: WeakSet<Selector>): K[];
5
+ export declare function getState<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(atom: Atom<Value>, data: StoreData, circularDependencySet?: WeakSet<Selector>): Value;
6
+ export declare function getState<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(selector: Selector<Value>, data: StoreData, circularDependencySet?: WeakSet<Selector>): Value;
7
+ export declare function getState<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(family: AtomFamily<Value, Args>, data: StoreData, circularDependencySet?: WeakSet<Selector>): Args[];
@@ -2,4 +2,4 @@ import type { Atom } from "../types/Atom";
2
2
  import type { AtomFamilyAtom } from "../types/AtomFamilyAtom";
3
3
  import type { StoreData } from "../types/StoreData";
4
4
  export declare const getAtomInitValue: <V = any>(atom: Atom<V>, data: StoreData) => any;
5
- export declare const initAtom: <V, K>(atom: Atom<V> | AtomFamilyAtom<K, V>, data: StoreData) => V;
5
+ export declare const initAtom: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(atom: Atom<Value> | AtomFamilyAtom<Value, Args>, data: StoreData) => Value;
@@ -0,0 +1 @@
1
+ export declare const stringifyFamilyArgs: (...args: any[]) => string | number | boolean;
@@ -1,3 +1,3 @@
1
1
  import type { State } from "../types/State";
2
2
  import type { StoreData } from "../types/StoreData";
3
- export declare const updateStateSubscribers: <V>(state: State, data: StoreData) => void;
3
+ export declare const updateStateSubscribers: (state: State, data: StoreData) => void;
@@ -1,4 +1,4 @@
1
1
  import type { GetValue } from "./types/GetValue";
2
2
  import type { Selector } from "./types/Selector";
3
3
  import type { SelectorOptions } from "./types/SelectorOptions";
4
- export declare const selector: <Value, FamilyKey = undefined>(get: (get: GetValue, storeId: string) => Value, options?: SelectorOptions<Value>) => Selector<Value, FamilyKey>;
4
+ export declare const selector: <Value extends unknown, FamilyArgs extends [any, ...any[]] = [any, ...any[]]>(get: (get: GetValue, storeId: string) => Value | Promise<Value>, options?: SelectorOptions<Value>) => Selector<Value, FamilyArgs>;
@@ -1,4 +1,4 @@
1
+ import type { GetValue } from "./types/GetValue";
1
2
  import type { SelectorFamily } from "./types/SelectorFamily";
2
3
  import type { SelectorOptions } from "./types/SelectorOptions";
3
- import type { GetValue } from "./types/GetValue";
4
- export declare const selectorFamily: <Key, Value>(get: (key: Key) => (get: GetValue) => Value, options?: SelectorOptions<Value>) => SelectorFamily<Key, Value>;
4
+ export declare const selectorFamily: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(callback: (...args: Args) => (get: GetValue) => Value | Promise<Value>, options?: SelectorOptions<Value>) => SelectorFamily<Value, Args>;
@@ -1,12 +1,11 @@
1
1
  import type { Atom } from "./Atom";
2
2
  import type { AtomFamilyAtom } from "./AtomFamilyAtom";
3
- import type { FamilyKey } from "./FamilyKey";
4
3
  import type { Selector } from "./Selector";
5
- export type AtomFamily<Key = FamilyKey, Value = unknown> = {
6
- (key: Key): AtomFamilyAtom<Key, Value>;
7
- release: (key: Key) => void;
4
+ export type AtomFamily<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]> = {
5
+ (...args: Args): AtomFamilyAtom<Value, Args>;
6
+ release: (...args: Args) => void;
8
7
  name?: string;
9
- __valdresAtomFamilyMap: Map<Key, AtomFamilyAtom<Key, Value>>;
10
- __keysAtom: Atom<Set<Key>>;
11
- __keysSelector: Selector<Key[]>;
8
+ __valdresAtomFamilyMap: Map<Value, AtomFamilyAtom<Value, Args>>;
9
+ __keysAtom: Atom<Set<Args>>;
10
+ __keysSelector: Selector<Args[]>;
12
11
  };
@@ -1,6 +1,6 @@
1
1
  import type { Atom } from "./Atom";
2
2
  import type { AtomFamily } from "./AtomFamily";
3
- export type AtomFamilyAtom<Key = unknown, Value = unknown> = Atom<Value> & {
4
- family: AtomFamily<Key, Value>;
5
- familyKey: Key;
3
+ export type AtomFamilyAtom<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]> = Atom<Value> & {
4
+ family: AtomFamily<Value, Args>;
5
+ familyKey: Args;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import type { Selector } from "./Selector";
2
2
  import type { SelectorFamily } from "./SelectorFamily";
3
- type DefaultValueCallback<Key, Value> = (arg: Key) => Value | Promise<Value>;
4
- export type AtomFamilyDefaultValue<Key, Value> = undefined | Value | DefaultValueCallback<Key, Value> | Selector<Value> | SelectorFamily<Key, Value>;
3
+ type DefaultValueCallback<Value extends any, Args extends [any, ...any[]]> = (...args: Args) => Value | Promise<Value>;
4
+ export type AtomFamilyDefaultValue<Value extends any, Args extends [any, ...any[]]> = undefined | Value | DefaultValueCallback<Value, Args> | Selector<Value, Args> | SelectorFamily<Value, Args>;
5
5
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { AtomFamilyAtom } from "./AtomFamilyAtom";
2
2
  import type { GlobalAtom } from "./GlobalAtom";
3
- export type AtomFamilyGlobalAtom<Key = unknown, Value = unknown> = AtomFamilyAtom<Key, Value> & GlobalAtom<Value>;
3
+ export type AtomFamilyGlobalAtom<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]> = AtomFamilyAtom<Value, Args> & GlobalAtom<Value>;
@@ -1,6 +1,6 @@
1
1
  import type { Selector } from "./Selector";
2
2
  import type { SelectorFamily } from "./SelectorFamily";
3
- export type AtomFamilySelector<Value = unknown, Key = unknown> = Selector<Value> & {
4
- family: SelectorFamily<Key, Value>;
5
- familyKey: Key;
3
+ export type AtomFamilySelector<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]> = Selector<Value> & {
4
+ family: SelectorFamily<Value, Args>;
5
+ familyKey: Args;
6
6
  };
@@ -1 +1 @@
1
- export type EqualFunc<Value = any> = (a: Value, b: Value) => boolean;
1
+ export type EqualFunc<Value extends any> = (a: Value, b: Value) => boolean;
@@ -1,3 +1,3 @@
1
1
  import type { SelectorFamily } from "./SelectorFamily";
2
2
  import type { AtomFamily } from "./AtomFamily";
3
- export type Family<Key, Value = any> = AtomFamily<Key, Value> | SelectorFamily<Key, Value>;
3
+ export type Family<Value extends any, Args extends [any, ...any[]] = [any, ...any[]]> = AtomFamily<Value, Args> | SelectorFamily<Value, Args>;
@@ -2,7 +2,7 @@ import type { Atom } from "./Atom";
2
2
  import type { AtomFamily } from "./AtomFamily";
3
3
  import type { Selector } from "./Selector";
4
4
  export type GetValue = {
5
- <V>(atom: Atom<V>): V;
6
- <V>(selector: Selector<V>): V;
7
- <V, K>(family: AtomFamily<K, V>): K[];
5
+ <Value extends any>(atom: Atom<Value>): Value;
6
+ <Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(selector: Selector<Value, Args>): Value;
7
+ <Value extends any, Args extends [any, ...any[]]>(family: AtomFamily<Value, Args>): Args[];
8
8
  };
@@ -1,11 +1,11 @@
1
1
  import type { EqualFunc } from "./EqualFunc";
2
2
  import type { GetValue } from "./GetValue";
3
3
  import type { SelectorFamily } from "./SelectorFamily";
4
- export type Selector<Value = unknown, FamilyKey = undefined> = {
5
- get: (get: GetValue, storeId: string) => Value;
4
+ export type Selector<Value extends any = any, FamilyArgs extends [any, ...any[]] = [any, ...any[]]> = {
5
+ get: (get: GetValue, storeId: string) => Value | Promise<Value>;
6
6
  equal: EqualFunc<Value>;
7
7
  name?: string;
8
- family?: SelectorFamily<FamilyKey, Value>;
9
- familyKey?: FamilyKey;
8
+ family?: SelectorFamily<Value, FamilyArgs>;
9
+ familyKey?: FamilyArgs;
10
10
  onMount?: () => void | (() => void);
11
11
  };
@@ -1,6 +1,5 @@
1
- import type { FamilyKey } from "./FamilyKey";
2
1
  import type { Selector } from "./Selector";
3
- export type SelectorFamily<Key = FamilyKey, Value = unknown> = {
4
- (key: Key, defaultOverride?: any): Selector<Value>;
5
- __valdresSelectorFamilyMap: Map<Key, Selector<Value, Key>>;
2
+ export type SelectorFamily<Value extends any, Args extends [any, ...any[]]> = {
3
+ (...args: Args): Selector<Value, Args>;
4
+ __valdresSelectorFamilyMap: Map<Args, Selector<Value, Args>>;
6
5
  };
@@ -1,5 +1,5 @@
1
1
  import type { EqualFunc } from "./EqualFunc";
2
- export type SelectorOptions<Value> = {
2
+ export type SelectorOptions<Value extends any> = {
3
3
  name?: string;
4
4
  equal?: EqualFunc<Value>;
5
5
  };
@@ -1,4 +1,4 @@
1
1
  import type { Atom } from "./Atom";
2
2
  import type { AtomFamily } from "./AtomFamily";
3
3
  import type { Selector } from "./Selector";
4
- export type State<K = any, V = any> = Atom<V> | Selector<V> | AtomFamily<K, V>;
4
+ export type State<Value extends any = any, Args extends [any, ...any[]] = [any, ...any[]]> = Atom<Value> | Selector<Value> | AtomFamily<Value, Args>;
@@ -6,8 +6,8 @@ import type { ScopedStoreData, StoreData } from "./StoreData";
6
6
  import type { SubscribeFn } from "./SubscribeFn";
7
7
  import type { TransactionFn } from "./TransactionFn";
8
8
  type SetAtom = {
9
- <V, K>(atom: AtomFamilyAtom<K, V>, value: V): void;
10
- <V>(atom: Atom<V>, value: V): void;
9
+ <Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(atom: AtomFamilyAtom<Value, Args>, value: Value): void;
10
+ <Value extends any>(atom: Atom<Value>, value: Value): void;
11
11
  };
12
12
  export type Store<T = StoreData> = {
13
13
  data: T;
@@ -3,7 +3,7 @@ import type { Family } from "./Family";
3
3
  import type { Selector } from "./Selector";
4
4
  type UnsuscribeFn = () => void;
5
5
  export type SubscribeFn = {
6
- <V, K>(state: Family<K, V>, callback: (arg: K) => void, requireDeepEqualCheckBeforeCallback?: boolean): UnsuscribeFn;
7
- <V>(state: Atom<V> | Selector<V>, callback: () => void, requireDeepEqualCheckBeforeCallback?: boolean): UnsuscribeFn;
6
+ <Value extends any, Args extends [any, ...any[]] = [any, ...any[]]>(state: Family<Value, Args>, callback: (...args: Args) => void, requireDeepEqualCheckBeforeCallback?: boolean): UnsuscribeFn;
7
+ <Value extends any>(state: Atom<Value> | Selector<Value>, callback: () => void, requireDeepEqualCheckBeforeCallback?: boolean): UnsuscribeFn;
8
8
  };
9
9
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { AtomFamily } from "../types/AtomFamily";
2
- export declare const isAtomFamily: <K, V>(state: any) => state is AtomFamily<K, V>;
2
+ export declare const isAtomFamily: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(state: any) => state is AtomFamily<Value, Args>;
@@ -1 +1 @@
1
- export declare const isFamily: (state: any) => state is import("..").SelectorFamily<unknown, unknown> | import("..").AtomFamily<unknown, unknown>;
1
+ export declare const isFamily: (state: any) => state is import("..").SelectorFamily<unknown, [any, ...any[]]> | import("..").AtomFamily<unknown, [any, ...any[]]>;
@@ -1,2 +1,2 @@
1
1
  import type { AtomFamilyAtom } from "../types/AtomFamilyAtom";
2
- export declare const isFamilyAtom: <K, V>(state: any) => state is AtomFamilyAtom<K, V>;
2
+ export declare const isFamilyAtom: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(state: any) => state is AtomFamilyAtom<Value, Args>;
@@ -1,2 +1,2 @@
1
1
  import type { AtomFamilySelector } from "../types/AtomFamilySelector";
2
- export declare const isFamilySelector: <K, V>(state: any) => state is AtomFamilySelector<K, V>;
2
+ export declare const isFamilySelector: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(state: any) => state is AtomFamilySelector<Value, Args>;
@@ -1,3 +1,3 @@
1
1
  import type { AtomFamilyAtom } from "../types/AtomFamilyAtom";
2
2
  import type { AtomFamilySelector } from "../types/AtomFamilySelector";
3
- export declare const isFamilyState: <K, V>(state: any) => state is AtomFamilyAtom<K, V> | AtomFamilySelector<K, V>;
3
+ export declare const isFamilyState: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(state: any) => state is AtomFamilyAtom<Value, Args> | AtomFamilySelector<Value, Args>;
@@ -1,2 +1,2 @@
1
1
  import type { SelectorFamily } from "../types/SelectorFamily";
2
- export declare const isSelectorFamily: <K, V>(state: any) => state is SelectorFamily<K, V>;
2
+ export declare const isSelectorFamily: <Value extends unknown, Args extends [any, ...any[]] = [any, ...any[]]>(state: any) => state is SelectorFamily<Value, Args>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valdres",
3
- "version": "0.2.0-alpha.74",
3
+ "version": "0.2.0-alpha.75",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Eigil Sagafos"
@@ -36,5 +36,5 @@
36
36
  "access": "public",
37
37
  "registry": "https://registry.npmjs.org/"
38
38
  },
39
- "gitHead": "bff29372cef5badd771e1cc9ea59f4b3fb8a5dc3"
39
+ "gitHead": "c6757088042bf15b35010217442c65f2a5e666a7"
40
40
  }