@figliolia/galena 2.2.4 → 2.2.5
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/dist/cjs/Galena/Galena.js +3 -2
- package/dist/cjs/Galena/State.js +1 -1
- package/dist/mjs/Galena/Galena.js +3 -2
- package/dist/mjs/Galena/State.js +1 -1
- package/dist/types/Galena/Galena.d.ts +1 -4
- package/dist/types/Galena/State.d.ts +1 -1
- package/package.json +1 -1
- package/src/Galena/Galena.ts +4 -5
- package/src/Galena/State.ts +1 -1
|
@@ -77,9 +77,10 @@ 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, Model
|
|
80
|
+
composeState(name, initialState, Model) {
|
|
81
81
|
this.guardDuplicateStates(name, this.state);
|
|
82
|
-
const
|
|
82
|
+
const StateModel = Model || (State_1.State);
|
|
83
|
+
const state = new StateModel(name, initialState);
|
|
83
84
|
state.registerMiddleware(...this.middleware);
|
|
84
85
|
this.mutable[name] = state;
|
|
85
86
|
this.reIndexSubscriptions(name);
|
package/dist/cjs/Galena/State.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.State = void 0;
|
|
4
4
|
const types_1 = require("../Middleware/types");
|
|
5
5
|
const event_emitter_1 = require("@figliolia/event-emitter");
|
|
6
|
-
const types_2 = require("./types");
|
|
7
6
|
const Scheduler_1 = require("./Scheduler");
|
|
7
|
+
const types_2 = require("./types");
|
|
8
8
|
/**
|
|
9
9
|
* ### State
|
|
10
10
|
*
|
|
@@ -74,9 +74,10 @@ export class Galena extends Guards {
|
|
|
74
74
|
* state will automatically receive updates when your new unit of
|
|
75
75
|
* state updates
|
|
76
76
|
*/
|
|
77
|
-
composeState(name, initialState, Model
|
|
77
|
+
composeState(name, initialState, Model) {
|
|
78
78
|
this.guardDuplicateStates(name, this.state);
|
|
79
|
-
const
|
|
79
|
+
const StateModel = Model || (State);
|
|
80
|
+
const state = new StateModel(name, initialState);
|
|
80
81
|
state.registerMiddleware(...this.middleware);
|
|
81
82
|
this.mutable[name] = state;
|
|
82
83
|
this.reIndexSubscriptions(name);
|
package/dist/mjs/Galena/State.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MiddlewareEvents } from "../Middleware/types.js";
|
|
2
2
|
import { EventEmitter } from "@figliolia/event-emitter";
|
|
3
|
-
import { Priority } from "./types.js";
|
|
4
3
|
import { Scheduler } from "./Scheduler.js";
|
|
4
|
+
import { Priority } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* ### State
|
|
7
7
|
*
|
|
@@ -71,10 +71,7 @@ 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
|
|
75
|
-
new (name: string, initialState: S): State<S>;
|
|
76
|
-
clone<T_1>(state: T_1): T_1;
|
|
77
|
-
}): InstanceType<M>;
|
|
74
|
+
composeState<S extends Record<string, any>, M extends typeof State<S>>(name: string, initialState: S, Model?: M): InstanceType<M>;
|
|
78
75
|
/**
|
|
79
76
|
* Get State
|
|
80
77
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figliolia/galena",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "A performant state management library supporting mutable state, batched updates, middleware and a rich development API",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/mjs/index.js",
|
package/src/Galena/Galena.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AutoIncrementingID } from "@figliolia/event-emitter";
|
|
2
|
-
|
|
3
2
|
import type { Middleware } from "Middleware/Middleware";
|
|
4
|
-
|
|
5
3
|
import { State } from "Galena/State";
|
|
6
4
|
import { Guards } from "./Guards";
|
|
7
5
|
|
|
@@ -84,13 +82,14 @@ export class Galena<
|
|
|
84
82
|
* state will automatically receive updates when your new unit of
|
|
85
83
|
* state updates
|
|
86
84
|
*/
|
|
87
|
-
public composeState<S extends
|
|
85
|
+
public composeState<S extends Record<string, any>, M extends typeof State<S>>(
|
|
88
86
|
name: string,
|
|
89
87
|
initialState: S,
|
|
90
|
-
Model
|
|
88
|
+
Model?: M
|
|
91
89
|
) {
|
|
92
90
|
this.guardDuplicateStates(name, this.state);
|
|
93
|
-
const
|
|
91
|
+
const StateModel = Model || State<S>;
|
|
92
|
+
const state = new StateModel(name, initialState);
|
|
94
93
|
state.registerMiddleware(...this.middleware);
|
|
95
94
|
this.mutable[name] = state;
|
|
96
95
|
this.reIndexSubscriptions(name);
|
package/src/Galena/State.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MiddlewareEvents } from "Middleware/types";
|
|
2
2
|
import type { Middleware } from "Middleware/Middleware";
|
|
3
3
|
import { EventEmitter } from "@figliolia/event-emitter";
|
|
4
|
-
import { Priority, type MutationEvent } from "./types";
|
|
5
4
|
import { Scheduler } from "./Scheduler";
|
|
5
|
+
import { Priority, type MutationEvent } from "./types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ### State
|