@yaasl/react 0.8.0-alpha.3 → 0.8.0

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,3 +1,2 @@
1
1
  export { useAtom, useSetAtom, useAtomValue, useAtomDidInit } from "./useAtom";
2
- export { useDerive, useSetDerive, useDeriveValue } from "./useDerive";
3
2
  export * from "@yaasl/core";
@@ -1,9 +1,9 @@
1
- import { Atom, Stateful } from "@yaasl/core";
1
+ import { Stateful } from "@yaasl/core";
2
2
  /** Use an atom's value in the react lifecycle.
3
3
  *
4
4
  * @param atom Atom to be used.
5
5
  *
6
- * @returns A stateful value.
6
+ * @returns The atom's value.
7
7
  **/
8
8
  export declare const useAtomValue: <ValueType>(atom: Stateful<ValueType>) => ValueType;
9
9
  /** Set an atom's value in the react lifecycle.
@@ -12,20 +12,18 @@ export declare const useAtomValue: <ValueType>(atom: Stateful<ValueType>) => Val
12
12
  *
13
13
  * @returns A setter function for the atom.
14
14
  **/
15
- export declare const useSetAtom: <ValueType>(atom: Atom<ValueType>) => (next: import("react").SetStateAction<ValueType>) => void;
15
+ export declare const useSetAtom: <ValueType>(atom: Stateful<ValueType>) => (next: import("react").SetStateAction<ValueType>) => void;
16
16
  /** Use an atom's initialization state in the react lifecycle.
17
17
  *
18
18
  * @param atom Atom to be used.
19
19
  *
20
20
  * @returns A boolean indicating if the atom has finished initializing yet.
21
21
  **/
22
- export declare const useAtomDidInit: <ValueType>(atom: Atom<ValueType>) => boolean;
22
+ export declare const useAtomDidInit: <ValueType>(atom: Stateful<ValueType>) => boolean;
23
23
  /** Use an atom's value and setter in the react lifecycle.
24
- *
25
- * **Note:** Use `useAtomValue` or `useSetAtom` to use value or setter separately.
26
24
  *
27
25
  * @param atom Atom to be used.
28
26
  *
29
27
  * @returns [value, setValue, didInit]
30
28
  **/
31
- export declare const useAtom: <ValueType>(atom: Atom<ValueType>) => readonly [ValueType, (next: import("react").SetStateAction<ValueType>) => void, boolean];
29
+ export declare const useAtom: <ValueType>(atom: Stateful<ValueType>) => readonly [ValueType, (next: import("react").SetStateAction<ValueType>) => void, boolean];
package/dist/cjs/index.js CHANGED
@@ -14,14 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useDeriveValue = exports.useSetDerive = exports.useDerive = exports.useAtomDidInit = exports.useAtomValue = exports.useSetAtom = exports.useAtom = void 0;
17
+ exports.useAtomDidInit = exports.useAtomValue = exports.useSetAtom = exports.useAtom = void 0;
18
18
  var useAtom_1 = require("./useAtom");
19
19
  Object.defineProperty(exports, "useAtom", { enumerable: true, get: function () { return useAtom_1.useAtom; } });
20
20
  Object.defineProperty(exports, "useSetAtom", { enumerable: true, get: function () { return useAtom_1.useSetAtom; } });
21
21
  Object.defineProperty(exports, "useAtomValue", { enumerable: true, get: function () { return useAtom_1.useAtomValue; } });
22
22
  Object.defineProperty(exports, "useAtomDidInit", { enumerable: true, get: function () { return useAtom_1.useAtomDidInit; } });
23
- var useDerive_1 = require("./useDerive");
24
- Object.defineProperty(exports, "useDerive", { enumerable: true, get: function () { return useDerive_1.useDerive; } });
25
- Object.defineProperty(exports, "useSetDerive", { enumerable: true, get: function () { return useDerive_1.useSetDerive; } });
26
- Object.defineProperty(exports, "useDeriveValue", { enumerable: true, get: function () { return useDerive_1.useDeriveValue; } });
27
23
  __exportStar(require("@yaasl/core"), exports);
@@ -7,7 +7,7 @@ const useStateful_1 = require("./useStateful");
7
7
  *
8
8
  * @param atom Atom to be used.
9
9
  *
10
- * @returns A stateful value.
10
+ * @returns The atom's value.
11
11
  **/
12
12
  const useAtomValue = (atom) => (0, useStateful_1.useStatefulValue)(atom);
13
13
  exports.useAtomValue = useAtomValue;
@@ -36,8 +36,6 @@ const useAtomDidInit = (atom) => {
36
36
  };
37
37
  exports.useAtomDidInit = useAtomDidInit;
38
38
  /** Use an atom's value and setter in the react lifecycle.
39
- *
40
- * **Note:** Use `useAtomValue` or `useSetAtom` to use value or setter separately.
41
39
  *
42
40
  * @param atom Atom to be used.
43
41
  *
package/dist/mjs/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export { useAtom, useSetAtom, useAtomValue, useAtomDidInit } from "./useAtom";
2
- export { useDerive, useSetDerive, useDeriveValue } from "./useDerive";
3
2
  export * from "@yaasl/core";
@@ -4,7 +4,7 @@ import { useSetStateful, useStatefulValue } from "./useStateful";
4
4
  *
5
5
  * @param atom Atom to be used.
6
6
  *
7
- * @returns A stateful value.
7
+ * @returns The atom's value.
8
8
  **/
9
9
  export const useAtomValue = (atom) => useStatefulValue(atom);
10
10
  /** Set an atom's value in the react lifecycle.
@@ -30,8 +30,6 @@ export const useAtomDidInit = (atom) => {
30
30
  return didInit;
31
31
  };
32
32
  /** Use an atom's value and setter in the react lifecycle.
33
- *
34
- * **Note:** Use `useAtomValue` or `useSetAtom` to use value or setter separately.
35
33
  *
36
34
  * @param atom Atom to be used.
37
35
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaasl/react",
3
- "version": "0.8.0-alpha.3",
3
+ "version": "0.8.0",
4
4
  "description": "yet another atomic store library (react)",
5
5
  "author": "PrettyCoffee",
6
6
  "license": "MIT",
@@ -41,13 +41,13 @@
41
41
  "react": ">=17"
42
42
  },
43
43
  "dependencies": {
44
- "@yaasl/core": "0.8.0-alpha.3",
45
- "@yaasl/utils": "0.8.0-alpha.3"
44
+ "@yaasl/core": "0.8.0",
45
+ "@yaasl/utils": "0.8.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@testing-library/react": "^14.2.1",
49
- "@types/react": "^18.2.56",
50
- "react": "^18.2.0"
48
+ "@testing-library/react": "^14.3.1",
49
+ "@types/react": "^18.3.1",
50
+ "react": "^18.3.1"
51
51
  },
52
52
  "eslintConfig": {
53
53
  "extends": [
@@ -1,24 +0,0 @@
1
- import { Derive } from "@yaasl/core";
2
- /** Use a derive atom's value in the react lifecycle.
3
- *
4
- * @param derive Derive atom to be used.
5
- *
6
- * @returns A stateful value.
7
- **/
8
- export declare const useDeriveValue: <ValueType>(derive: Derive<ValueType>) => ValueType;
9
- /** Set a derive atom's value in the react lifecycle.
10
- *
11
- * @param derive Derive atom to be used.
12
- *
13
- * @returns A setter function for the derive atom.
14
- **/
15
- export declare const useSetDerive: <ValueType>(derive: Derive<ValueType>) => (next: import("react").SetStateAction<ValueType>) => void;
16
- /** Use a derive atom's value and setter in the react lifecycle.
17
- *
18
- * **Note:** Use `useDeriveValue` or `useSetDerive` to use value or setter separately.
19
- *
20
- * @param derive Derive atom to be used.
21
- *
22
- * @returns [value, setValue]
23
- **/
24
- export declare const useDerive: <ValueType>(derive: Derive<ValueType>) => readonly [ValueType, (next: import("react").SetStateAction<ValueType>) => void];
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDerive = exports.useSetDerive = exports.useDeriveValue = void 0;
4
- const useStateful_1 = require("./useStateful");
5
- /** Use a derive atom's value in the react lifecycle.
6
- *
7
- * @param derive Derive atom to be used.
8
- *
9
- * @returns A stateful value.
10
- **/
11
- const useDeriveValue = (derive) => (0, useStateful_1.useStatefulValue)(derive);
12
- exports.useDeriveValue = useDeriveValue;
13
- /** Set a derive atom's value in the react lifecycle.
14
- *
15
- * @param derive Derive atom to be used.
16
- *
17
- * @returns A setter function for the derive atom.
18
- **/
19
- const useSetDerive = (derive) => (0, useStateful_1.useSetStateful)(derive);
20
- exports.useSetDerive = useSetDerive;
21
- /** Use a derive atom's value and setter in the react lifecycle.
22
- *
23
- * **Note:** Use `useDeriveValue` or `useSetDerive` to use value or setter separately.
24
- *
25
- * @param derive Derive atom to be used.
26
- *
27
- * @returns [value, setValue]
28
- **/
29
- const useDerive = (derive) => {
30
- const state = (0, exports.useDeriveValue)(derive);
31
- const setState = (0, exports.useSetDerive)(derive);
32
- return [state, setState];
33
- };
34
- exports.useDerive = useDerive;
@@ -1,28 +0,0 @@
1
- import { useSetStateful, useStatefulValue } from "./useStateful";
2
- /** Use a derive atom's value in the react lifecycle.
3
- *
4
- * @param derive Derive atom to be used.
5
- *
6
- * @returns A stateful value.
7
- **/
8
- export const useDeriveValue = (derive) => useStatefulValue(derive);
9
- /** Set a derive atom's value in the react lifecycle.
10
- *
11
- * @param derive Derive atom to be used.
12
- *
13
- * @returns A setter function for the derive atom.
14
- **/
15
- export const useSetDerive = (derive) => useSetStateful(derive);
16
- /** Use a derive atom's value and setter in the react lifecycle.
17
- *
18
- * **Note:** Use `useDeriveValue` or `useSetDerive` to use value or setter separately.
19
- *
20
- * @param derive Derive atom to be used.
21
- *
22
- * @returns [value, setValue]
23
- **/
24
- export const useDerive = (derive) => {
25
- const state = useDeriveValue(derive);
26
- const setState = useSetDerive(derive);
27
- return [state, setState];
28
- };