@yaasl/core 0.9.1 → 0.9.2
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,6 +1,7 @@
|
|
|
1
1
|
type Callback<Value> = (value: Value, previous: Value) => void;
|
|
2
2
|
export declare class Stateful<Value = unknown> {
|
|
3
3
|
protected value: Value;
|
|
4
|
+
/** Promise that resolves when the states initialization was finished. */
|
|
4
5
|
didInit: PromiseLike<void> | boolean;
|
|
5
6
|
private listeners;
|
|
6
7
|
constructor(value: Value);
|
|
@@ -13,8 +13,11 @@ export interface AtomConfig<Value, R extends Reducers<Value> = Reducers<Value>>
|
|
|
13
13
|
reducers?: R;
|
|
14
14
|
}
|
|
15
15
|
export declare class Atom<Value = unknown, R extends Reducers<Value> = Reducers<Value>> extends Stateful<Value> {
|
|
16
|
+
/** Default value of the atom. */
|
|
16
17
|
readonly defaultValue: Value;
|
|
18
|
+
/** Identifier of the atom. */
|
|
17
19
|
readonly name: string;
|
|
20
|
+
/** Actions that can be used to set the atom's value. */
|
|
18
21
|
readonly actions: Actions<Value, R>;
|
|
19
22
|
constructor({ defaultValue, name, effects, reducers, }: AtomConfig<Value, R>);
|
|
20
23
|
/** Set the value of the atom.
|
|
@@ -32,11 +35,5 @@ export declare class Atom<Value = unknown, R extends Reducers<Value> = Reducers<
|
|
|
32
35
|
* @param config.reducers Reducers for custom actions to set the atom's value.
|
|
33
36
|
*
|
|
34
37
|
* @returns An atom instance.
|
|
35
|
-
* - `result.get`: Read the value of state.
|
|
36
|
-
* - `result.subscribe`: Subscribe to value changes.
|
|
37
|
-
* - `result.set`: Set the value of the atom.
|
|
38
|
-
* - `result.actions`: All actions that were created with reducers.
|
|
39
|
-
* - `result.didInit`: State of the atom's effects initialization process.
|
|
40
|
-
* Will be a promise if the initialization is pending and `true` if finished.
|
|
41
38
|
**/
|
|
42
39
|
export declare const createAtom: <Value, R extends Reducers<Value> = Reducers<Value>>(config: AtomConfig<Value, R>) => Atom<Value, R>;
|
|
@@ -37,12 +37,6 @@ exports.Atom = Atom;
|
|
|
37
37
|
* @param config.reducers Reducers for custom actions to set the atom's value.
|
|
38
38
|
*
|
|
39
39
|
* @returns An atom instance.
|
|
40
|
-
* - `result.get`: Read the value of state.
|
|
41
|
-
* - `result.subscribe`: Subscribe to value changes.
|
|
42
|
-
* - `result.set`: Set the value of the atom.
|
|
43
|
-
* - `result.actions`: All actions that were created with reducers.
|
|
44
|
-
* - `result.didInit`: State of the atom's effects initialization process.
|
|
45
|
-
* Will be a promise if the initialization is pending and `true` if finished.
|
|
46
40
|
**/
|
|
47
41
|
const createAtom = (config) => new Atom(config);
|
|
48
42
|
exports.createAtom = createAtom;
|
|
@@ -33,11 +33,5 @@ export class Atom extends Stateful {
|
|
|
33
33
|
* @param config.reducers Reducers for custom actions to set the atom's value.
|
|
34
34
|
*
|
|
35
35
|
* @returns An atom instance.
|
|
36
|
-
* - `result.get`: Read the value of state.
|
|
37
|
-
* - `result.subscribe`: Subscribe to value changes.
|
|
38
|
-
* - `result.set`: Set the value of the atom.
|
|
39
|
-
* - `result.actions`: All actions that were created with reducers.
|
|
40
|
-
* - `result.didInit`: State of the atom's effects initialization process.
|
|
41
|
-
* Will be a promise if the initialization is pending and `true` if finished.
|
|
42
36
|
**/
|
|
43
37
|
export const createAtom = (config) => new Atom(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaasl/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "yet another atomic store library (vanilla-js)",
|
|
5
5
|
"author": "PrettyCoffee",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"validate": "run-s lint test build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@yaasl/utils": "0.9.
|
|
41
|
+
"@yaasl/utils": "0.9.2"
|
|
42
42
|
},
|
|
43
43
|
"eslintConfig": {
|
|
44
44
|
"extends": [
|