@adaas/a-utils 0.2.3 → 0.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/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/lib/A-Channel/A-Channel.component.ts +1 -1
- package/src/lib/A-Signal/components/A-SignalBus.component.ts +8 -7
- package/src/lib/A-Signal/context/A-SignalState.context.ts +26 -0
- package/tests/A-Command.test.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A-Utils is a set of utilities that are used across the ADAAS ecosystem. This package is designed to be a collection of utilities that are used across the ADAAS ecosystem.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"build": "tsup --config tsup.config.ts"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@adaas/a-concept": "^0.
|
|
84
|
-
"@adaas/a-frame": "^0.0.
|
|
83
|
+
"@adaas/a-concept": "^0.2.5",
|
|
84
|
+
"@adaas/a-frame": "^0.0.7"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/chai": "^4.3.14",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_Component, A_Context,
|
|
1
|
+
import { A_Component, A_Context, A_Feature, A_IdentityHelper, A_Scope } from "@adaas/a-concept";
|
|
2
2
|
import { A_ChannelError } from "./A-Channel.error";
|
|
3
3
|
import { A_ChannelFeatures } from "./A-Channel.constants";
|
|
4
4
|
import { A_OperationContext } from "../A-Operation/A-Operation.context";
|
|
@@ -40,6 +40,7 @@ export class A_SignalBus extends A_Component {
|
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
42
|
await this.call(A_SignalBusFeatures.onBeforeNext, scope);
|
|
43
|
+
|
|
43
44
|
await this.call(A_SignalBusFeatures.onNext, scope);
|
|
44
45
|
|
|
45
46
|
scope.destroy();
|
|
@@ -138,8 +139,9 @@ export class A_SignalBus extends A_Component {
|
|
|
138
139
|
before: /.*/
|
|
139
140
|
})
|
|
140
141
|
async [A_SignalBusFeatures.onNext](
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
@A_Dependency.Flat()
|
|
143
|
+
@A_Dependency.All()
|
|
144
|
+
@A_Inject(A_Signal) signals: A_Signal[],
|
|
143
145
|
@A_Inject(A_Scope) scope: A_Scope,
|
|
144
146
|
|
|
145
147
|
@A_Dependency.Required()
|
|
@@ -155,7 +157,7 @@ export class A_SignalBus extends A_Component {
|
|
|
155
157
|
3) the bus should listen for all emitted signals within the scope
|
|
156
158
|
4) when a signal is emitted, the bus should store a signal in some place (probably it's memory)
|
|
157
159
|
*/
|
|
158
|
-
const signals = scope.resolveFlatAll<A_Signal>(A_Signal);
|
|
160
|
+
// const signals = scope.resolveFlatAll<A_Signal>(A_Signal);
|
|
159
161
|
|
|
160
162
|
for (const signal of signals) {
|
|
161
163
|
|
|
@@ -169,11 +171,10 @@ export class A_SignalBus extends A_Component {
|
|
|
169
171
|
logger?.debug(`A_SignalBus: Updating state for signal '${signal.constructor.name}' with data:`, signal.data);
|
|
170
172
|
|
|
171
173
|
state.set(signal);
|
|
174
|
+
}
|
|
172
175
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
scope.register(vector);
|
|
176
|
+
const vector = state.toVector();
|
|
176
177
|
|
|
177
|
-
|
|
178
|
+
scope.register(vector);
|
|
178
179
|
}
|
|
179
180
|
}
|
|
@@ -32,6 +32,13 @@ export class A_SignalState<
|
|
|
32
32
|
*/
|
|
33
33
|
protected _state: Map<A_TYPES__Component_Constructor<A_Signal>, A_Signal> = new Map();
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Previous state map to track changes between signal emissions
|
|
37
|
+
* Key: Signal constructor function
|
|
38
|
+
* Value: Previous emitted data from that signal type
|
|
39
|
+
*/
|
|
40
|
+
protected _prevState: Map<A_TYPES__Component_Constructor<A_Signal>, A_Signal> = new Map();
|
|
41
|
+
|
|
35
42
|
/**
|
|
36
43
|
* Optional structure defining the ordered list of signal constructors
|
|
37
44
|
* Used for vector operations and initialization
|
|
@@ -91,6 +98,7 @@ export class A_SignalState<
|
|
|
91
98
|
const signal = param1 instanceof A_Signal ? param1.constructor as A_TYPES__Component_Constructor<A_Signal> : param1;
|
|
92
99
|
const value = param1 instanceof A_Signal ? param1 : param2!;
|
|
93
100
|
|
|
101
|
+
this._prevState.set(signal, this._state.get(signal)!);
|
|
94
102
|
this._state.set(signal, value);
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -113,6 +121,24 @@ export class A_SignalState<
|
|
|
113
121
|
return this._state.get(signal);
|
|
114
122
|
}
|
|
115
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves the previous value for a specific signal type
|
|
126
|
+
*
|
|
127
|
+
* @param signal
|
|
128
|
+
*/
|
|
129
|
+
getPrev(
|
|
130
|
+
signal: A_Signal
|
|
131
|
+
): A_Signal | undefined
|
|
132
|
+
getPrev(
|
|
133
|
+
signal: A_TYPES__Component_Constructor<A_Signal>
|
|
134
|
+
): A_Signal | undefined
|
|
135
|
+
getPrev(
|
|
136
|
+
param: A_TYPES__Component_Constructor<A_Signal> | A_Signal
|
|
137
|
+
): A_Signal | undefined {
|
|
138
|
+
const signal = param instanceof A_Signal ? param.constructor as A_TYPES__Component_Constructor<A_Signal> : param;
|
|
139
|
+
return this._prevState.get(signal);
|
|
140
|
+
}
|
|
141
|
+
|
|
116
142
|
/**
|
|
117
143
|
* Checks if a signal type has been registered in the state
|
|
118
144
|
*
|
package/tests/A-Command.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { A_Memory } from '@adaas/a-utils/lib/A-Memory/A-Memory.component';
|
|
|
7
7
|
import { A_MemoryContext } from '@adaas/a-utils/lib/A-Memory/A-Memory.context';
|
|
8
8
|
import { A_Channel } from '@adaas/a-utils/lib/A-Channel/A-Channel.component';
|
|
9
9
|
import { A_ChannelRequest } from '@adaas/a-utils/lib/A-Channel/A-ChannelRequest.context';
|
|
10
|
-
import { A_Caller, A_Component, A_Concept, A_Container, A_Context, A_Error, A_Feature, A_FormatterHelper, A_Inject, A_Scope, ASEID } from '@adaas/a-concept';
|
|
10
|
+
import { A_Caller, A_Component, A_Concept, A_Container, A_Context, A_Dependency, A_Error, A_Feature, A_FormatterHelper, A_Inject, A_Scope, ASEID } from '@adaas/a-concept';
|
|
11
11
|
|
|
12
12
|
jest.retryTimes(0);
|
|
13
13
|
|
|
@@ -494,12 +494,12 @@ describe('A-Command tests', () => {
|
|
|
494
494
|
template: [
|
|
495
495
|
{
|
|
496
496
|
name: 'itemName',
|
|
497
|
-
|
|
497
|
+
dependency: new A_Dependency('ItemNameHandler'),
|
|
498
498
|
handler: 'getName'
|
|
499
499
|
},
|
|
500
500
|
{
|
|
501
501
|
name: 'itemPrice',
|
|
502
|
-
|
|
502
|
+
dependency: new A_Dependency('ItemPriceHandler'),
|
|
503
503
|
handler: 'getPrice'
|
|
504
504
|
}
|
|
505
505
|
]
|