@adaas/a-utils 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaas/a-utils",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
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.1.61",
84
- "@adaas/a-frame": "^0.0.2"
83
+ "@adaas/a-concept": "^0.2.3",
84
+ "@adaas/a-frame": "^0.0.5"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/chai": "^4.3.14",
@@ -1,4 +1,4 @@
1
- import { A_Component, A_Context, A_Error, A_Feature, A_IdentityHelper, A_Inject, A_Scope, A_TYPES__InjectableConstructors, A_TYPES__InjectableTargets } from "@adaas/a-concept";
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();
@@ -169,11 +170,10 @@ export class A_SignalBus extends A_Component {
169
170
  logger?.debug(`A_SignalBus: Updating state for signal '${signal.constructor.name}' with data:`, signal.data);
170
171
 
171
172
  state.set(signal);
173
+ }
172
174
 
173
- const vector = state.toVector();
174
-
175
- scope.register(vector);
175
+ const vector = state.toVector();
176
176
 
177
- }
177
+ scope.register(vector);
178
178
  }
179
179
  }
@@ -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
  *
@@ -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
- component: 'ItemNameHandler',
497
+ dependency: new A_Dependency('ItemNameHandler'),
498
498
  handler: 'getName'
499
499
  },
500
500
  {
501
501
  name: 'itemPrice',
502
- component: 'ItemPriceHandler',
502
+ dependency: new A_Dependency('ItemPriceHandler'),
503
503
  handler: 'getPrice'
504
504
  }
505
505
  ]