chem-rx 0.0.13 → 0.0.14

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.
@@ -1,5 +1,5 @@
1
1
  import { BaseAtom, NullableBaseAtom } from "./Atom";
2
- export declare function useSelectAtom<T extends NullableBaseAtom<V> | BaseAtom<V>, V extends {
3
- [key in K]: infer W;
4
- }, K extends keyof V>(atom: T, key: K): V[K];
2
+ export declare function useSelectAtom<T extends {
3
+ [key in K]: V;
4
+ }, K extends keyof T, V = T[K]>(atom: NullableBaseAtom<T> | BaseAtom<T>, key: K): T[K];
5
5
  //# sourceMappingURL=useSelectAtom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectAtom.d.ts","sourceRoot":"","sources":["../src/useSelectAtom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEpD,wBAAgB,aAAa,CAC3B,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAC3C,CAAC,SAAS;KACP,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;CACpB,EACD,CAAC,SAAS,MAAM,CAAC,EACjB,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAcvB"}
1
+ {"version":3,"file":"useSelectAtom.d.ts","sourceRoot":"","sources":["../src/useSelectAtom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEpD,wBAAgB,aAAa,CAC3B,CAAC,SAAS;KACP,GAAG,IAAI,CAAC,GAAG,CAAC;CACd,EACD,CAAC,SAAS,MAAM,CAAC,EACjB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EACR,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAcvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chem-rx",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "react state primitives powered by rx.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,17 +2,17 @@ import { useEffect, useState } from "react";
2
2
  import { BaseAtom, NullableBaseAtom } from "./Atom";
3
3
 
4
4
  export function useSelectAtom<
5
- T extends NullableBaseAtom<V> | BaseAtom<V>,
6
- V extends {
7
- [key in K]: infer W;
5
+ T extends {
6
+ [key in K]: V;
8
7
  },
9
- K extends keyof V
10
- >(atom: T, key: K): V[K] {
11
- const [value, setValue] = useState<V[K]>(atom.get(key)!);
8
+ K extends keyof T,
9
+ V = T[K]
10
+ >(atom: NullableBaseAtom<T> | BaseAtom<T>, key: K): T[K] {
11
+ const [value, setValue] = useState<T[K]>(atom.get(key)!);
12
12
 
13
13
  useEffect(() => {
14
14
  const subscription = atom.select(key).subscribe((val) => {
15
- setValue(val as V[K]);
15
+ setValue(val as T[K]);
16
16
  });
17
17
 
18
18
  return () => {
@@ -449,7 +449,8 @@ test("Test select nullable object", () => {
449
449
  };
450
450
  }>();
451
451
 
452
- // const newVal = nestedData.select("stacy");
452
+ // TODO: This errors
453
+ const newVal = nestedData.select("stacy");
453
454
 
454
455
  nestedData.next(seedData);
455
456
  const stacy = nestedData.select("stacy");