@adaas/a-utils 0.1.32 → 0.1.33
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 +24 -6
- package/dist/index.d.ts +24 -6
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Signal/A-Signal.constants.ts +3 -3
- package/src/lib/A-Signal/A-Signal.types.ts +3 -0
- package/src/lib/A-Signal/components/A-SignalBus.component.ts +3 -20
- package/src/lib/A-Signal/entities/A-Signal.entity.ts +2 -2
- package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +47 -1
- package/tests/A-Signal.test.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
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",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
export enum A_SignalFeatures {
|
|
3
|
-
|
|
3
|
+
Next = '_A_SignalFeatures_Next',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
export enum
|
|
9
|
-
|
|
8
|
+
export enum A_SignalVectorFeatures {
|
|
9
|
+
Next = '_A_SignalVectorFeatures_Next',
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A_Caller, A_Component, A_Context, A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
|
-
import {
|
|
2
|
+
import { A_SignalFeatures } from "../A-Signal.constants";
|
|
3
3
|
import { A_SignalState } from "../context/A-SignalState.context";
|
|
4
4
|
import { A_SignalConfig } from "../context/A-SignalConfig.context";
|
|
5
5
|
import { A_Config } from "../../A-Config/A-Config.context";
|
|
@@ -36,7 +36,7 @@ export class A_SignalBus extends A_Component {
|
|
|
36
36
|
@A_Feature.Extend({
|
|
37
37
|
scope: [A_Signal]
|
|
38
38
|
})
|
|
39
|
-
async [A_SignalFeatures.
|
|
39
|
+
async [A_SignalFeatures.Next](
|
|
40
40
|
@A_Inject(A_Caller) signal: A_Signal,
|
|
41
41
|
@A_Inject(A_Scope) scope: A_Scope,
|
|
42
42
|
|
|
@@ -90,23 +90,6 @@ export class A_SignalBus extends A_Component {
|
|
|
90
90
|
|
|
91
91
|
const vector = state.toVector();
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
name: `A_SignalBus_Next_Scope_of_${this.constructor.name}`,
|
|
95
|
-
entities: [vector]
|
|
96
|
-
})
|
|
97
|
-
.inherit(scope);
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
|
|
101
|
-
await this.call(A_SignalBusFeatures.Emit, nextScope);
|
|
102
|
-
|
|
103
|
-
nextScope.destroy();
|
|
104
|
-
|
|
105
|
-
} catch (error) {
|
|
106
|
-
|
|
107
|
-
nextScope.destroy();
|
|
108
|
-
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
93
|
+
await vector.next(scope);
|
|
111
94
|
}
|
|
112
95
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A_Entity, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor } from "@adaas/a-concept";
|
|
1
|
+
import { A_Entity, A_Scope, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor } from "@adaas/a-concept";
|
|
2
2
|
import { A_SignalVector_Serialized, A_SignalVector_Init } from "../A-Signal.types";
|
|
3
3
|
import { A_Signal } from "./A-Signal.entity";
|
|
4
|
+
import { A_SignalVectorFeatures } from "../A-Signal.constants";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -57,6 +58,46 @@ export class A_SignalVector<
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Enables iteration over the signals in the vector.
|
|
63
|
+
*
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
[Symbol.iterator](): Iterator<TSignals[number]> {
|
|
67
|
+
let pointer = 0;
|
|
68
|
+
const signals = this.structure.map((signalConstructor) => {
|
|
69
|
+
const signalIndex = this._signals.findIndex(s => s.constructor === signalConstructor);
|
|
70
|
+
return signalIndex !== -1 ? this._signals[signalIndex] : undefined;
|
|
71
|
+
}) as TSignals[number][];
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
next(): IteratorResult<TSignals[number]> {
|
|
75
|
+
if (pointer < signals.length) {
|
|
76
|
+
return {
|
|
77
|
+
done: false,
|
|
78
|
+
value: signals[pointer++]
|
|
79
|
+
};
|
|
80
|
+
} else {
|
|
81
|
+
return {
|
|
82
|
+
done: true,
|
|
83
|
+
value: undefined as any
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Emits the signal vector to the specified scope.
|
|
93
|
+
*
|
|
94
|
+
* @param scope
|
|
95
|
+
*/
|
|
96
|
+
async next(scope: A_Scope): Promise<void> {
|
|
97
|
+
return await this.call(A_SignalVectorFeatures.Next, scope);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
60
101
|
/**
|
|
61
102
|
* Checks if the vector contains a signal of the specified type.
|
|
62
103
|
*
|
|
@@ -74,6 +115,11 @@ export class A_SignalVector<
|
|
|
74
115
|
return this.structure.includes(signalConstructor);
|
|
75
116
|
}
|
|
76
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the signal of the specified type from the vector.
|
|
120
|
+
*
|
|
121
|
+
* @param signal
|
|
122
|
+
*/
|
|
77
123
|
get(signal: A_Signal): Record<string, any> | undefined
|
|
78
124
|
get(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): Record<string, any> | undefined
|
|
79
125
|
get(param1: A_Signal | A_TYPES__Component_Constructor<A_Signal>): Record<string, any> | undefined {
|
package/tests/A-Signal.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A_Component, A_Concept, A_Container, A_Context, A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
|
-
import {
|
|
1
|
+
import { A_Caller, A_Component, A_Concept, A_Container, A_Context, A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
|
+
import { A_SignalVectorFeatures } from "@adaas/a-utils/lib/A-Signal/A-Signal.constants";
|
|
3
3
|
import { A_SignalBus } from "@adaas/a-utils/lib/A-Signal/components/A-SignalBus.component";
|
|
4
4
|
import { A_SignalConfig } from "@adaas/a-utils/lib/A-Signal/context/A-SignalConfig.context";
|
|
5
5
|
import { A_Signal } from "@adaas/a-utils/lib/A-Signal/entities/A-Signal.entity";
|
|
@@ -27,13 +27,13 @@ describe('A-Signal tests', () => {
|
|
|
27
27
|
buttonId: 'submit-order'
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
|
-
await signal.
|
|
30
|
+
await signal.next(scope)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
@A_Feature.Extend()
|
|
35
|
-
async [
|
|
36
|
-
@A_Inject(
|
|
35
|
+
async [A_SignalVectorFeatures.Next](
|
|
36
|
+
@A_Inject(A_Caller) vector: A_SignalVector
|
|
37
37
|
) {
|
|
38
38
|
result = vector;
|
|
39
39
|
}
|
|
@@ -91,13 +91,13 @@ describe('A-Signal tests', () => {
|
|
|
91
91
|
}
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
-
await signal.
|
|
94
|
+
await signal.next(scope)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
@A_Feature.Extend()
|
|
99
|
-
async [
|
|
100
|
-
@A_Inject(
|
|
99
|
+
async [A_SignalVectorFeatures.Next](
|
|
100
|
+
@A_Inject(A_Caller) vector: A_SignalVector
|
|
101
101
|
) {
|
|
102
102
|
result = vector;
|
|
103
103
|
}
|