@figliolia/galena 2.0.9 → 2.1.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.
- package/README.md +8 -0
- package/dist/Galena/Galena.d.ts +10 -1
- package/dist/Galena/Galena.js +9 -3
- package/package.json +2 -2
- package/src/Galena/Galena.ts +11 -6
package/README.md
CHANGED
|
@@ -132,6 +132,14 @@ import type { State } from "@figliolia/galena";
|
|
|
132
132
|
|
|
133
133
|
const AppState = new Galena(/* middleware */ [new Logger(), new Profiler()]);
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Get State
|
|
137
|
+
*
|
|
138
|
+
* Returns the current state tree with each attached
|
|
139
|
+
* unit. The object returned is readonly
|
|
140
|
+
*/
|
|
141
|
+
AppState.getState();
|
|
142
|
+
|
|
135
143
|
/**
|
|
136
144
|
* Compose State
|
|
137
145
|
*
|
package/dist/Galena/Galena.d.ts
CHANGED
|
@@ -71,7 +71,16 @@ export declare class Galena<T extends Record<string, State<any>> = Record<string
|
|
|
71
71
|
* state will automatically receive updates when your new unit of
|
|
72
72
|
* state updates
|
|
73
73
|
*/
|
|
74
|
-
composeState<S extends any, M extends typeof State<S
|
|
74
|
+
composeState<S extends any, M extends typeof State<S>>(name: string, initialState: S, Model?: {
|
|
75
|
+
new (name: string, initialState: S): State<S>;
|
|
76
|
+
clone<T_1>(state: T_1): T_1;
|
|
77
|
+
}): InstanceType<M>;
|
|
78
|
+
/**
|
|
79
|
+
* Get State
|
|
80
|
+
*
|
|
81
|
+
* Returns a mutable state instance
|
|
82
|
+
*/
|
|
83
|
+
getState(): Readonly<T>;
|
|
75
84
|
/**
|
|
76
85
|
* Get
|
|
77
86
|
*
|
package/dist/Galena/Galena.js
CHANGED
|
@@ -77,9 +77,7 @@ class Galena extends Guards_1.Guards {
|
|
|
77
77
|
* state will automatically receive updates when your new unit of
|
|
78
78
|
* state updates
|
|
79
79
|
*/
|
|
80
|
-
composeState(name, initialState,
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
Model = (State_1.State)) {
|
|
80
|
+
composeState(name, initialState, Model = (State_1.State)) {
|
|
83
81
|
this.guardDuplicateStates(name, this.state);
|
|
84
82
|
const state = new Model(name, initialState);
|
|
85
83
|
state.registerMiddleware(...this.middleware);
|
|
@@ -87,6 +85,14 @@ class Galena extends Guards_1.Guards {
|
|
|
87
85
|
this.reIndexSubscriptions(name);
|
|
88
86
|
return state;
|
|
89
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get State
|
|
90
|
+
*
|
|
91
|
+
* Returns a mutable state instance
|
|
92
|
+
*/
|
|
93
|
+
getState() {
|
|
94
|
+
return this.state;
|
|
95
|
+
}
|
|
90
96
|
/**
|
|
91
97
|
* Get
|
|
92
98
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figliolia/galena",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A performant state management library supporting mutable state, batched updates, middleware and a rich development API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|
package/src/Galena/Galena.ts
CHANGED
|
@@ -84,14 +84,10 @@ export class Galena<
|
|
|
84
84
|
* state will automatically receive updates when your new unit of
|
|
85
85
|
* state updates
|
|
86
86
|
*/
|
|
87
|
-
public composeState<
|
|
88
|
-
S extends any,
|
|
89
|
-
M extends typeof State<S> = typeof State<S>
|
|
90
|
-
>(
|
|
87
|
+
public composeState<S extends any, M extends typeof State<S>>(
|
|
91
88
|
name: string,
|
|
92
89
|
initialState: S,
|
|
93
|
-
|
|
94
|
-
Model: M = State<S>
|
|
90
|
+
Model = State<S>
|
|
95
91
|
) {
|
|
96
92
|
this.guardDuplicateStates(name, this.state);
|
|
97
93
|
const state = new Model(name, initialState);
|
|
@@ -101,6 +97,15 @@ export class Galena<
|
|
|
101
97
|
return state as InstanceType<M>;
|
|
102
98
|
}
|
|
103
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Get State
|
|
102
|
+
*
|
|
103
|
+
* Returns a mutable state instance
|
|
104
|
+
*/
|
|
105
|
+
public getState() {
|
|
106
|
+
return this.state as Readonly<T>;
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
/**
|
|
105
110
|
* Get
|
|
106
111
|
*
|