ngssm-store 19.2.1 → 19.2.2

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.
@@ -89,10 +89,10 @@ class CachedItemReducer {
89
89
  }
90
90
  return state;
91
91
  }
92
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CachedItemReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
93
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CachedItemReducer }); }
92
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: CachedItemReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
93
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: CachedItemReducer }); }
94
94
  }
95
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: CachedItemReducer, decorators: [{
95
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: CachedItemReducer, decorators: [{
96
96
  type: Injectable
97
97
  }] });
98
98
 
@@ -135,10 +135,10 @@ class VisibilityReducer {
135
135
  elements: elementsCommand
136
136
  });
137
137
  }
138
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: VisibilityReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
139
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: VisibilityReducer }); }
138
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: VisibilityReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
139
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: VisibilityReducer }); }
140
140
  }
141
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: VisibilityReducer, decorators: [{
141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: VisibilityReducer, decorators: [{
142
142
  type: Injectable
143
143
  }] });
144
144
 
@@ -157,10 +157,10 @@ class ToggleElementVisibilityDirective {
157
157
  this.store.dispatchAction(new ToggleElementVisibilityAction(elementKey));
158
158
  }
159
159
  }
160
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ToggleElementVisibilityDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
161
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: ToggleElementVisibilityDirective, isStandalone: true, selector: "[toggleElementVisibility]", inputs: { key: ["toggleElementVisibility", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
160
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ToggleElementVisibilityDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
161
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: ToggleElementVisibilityDirective, isStandalone: true, selector: "[toggleElementVisibility]", inputs: { key: ["toggleElementVisibility", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
162
162
  }
163
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ToggleElementVisibilityDirective, decorators: [{
163
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ToggleElementVisibilityDirective, decorators: [{
164
164
  type: Directive,
165
165
  args: [{
166
166
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -179,10 +179,10 @@ class IsElementVisiblePipe {
179
179
  transform(value, ...args) {
180
180
  return selectNgssmVisibilityState(value).elements[args[0]] === true;
181
181
  }
182
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: IsElementVisiblePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
183
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: IsElementVisiblePipe, isStandalone: true, name: "isElementVisible" }); }
182
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: IsElementVisiblePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
183
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.4", ngImport: i0, type: IsElementVisiblePipe, isStandalone: true, name: "isElementVisible" }); }
184
184
  }
185
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: IsElementVisiblePipe, decorators: [{
185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: IsElementVisiblePipe, decorators: [{
186
186
  type: Pipe,
187
187
  args: [{
188
188
  name: 'isElementVisible',
@@ -201,10 +201,10 @@ class ShowElementDirective {
201
201
  this.store.dispatchAction(new ShowElementAction(elementKey));
202
202
  }
203
203
  }
204
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ShowElementDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
205
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: ShowElementDirective, isStandalone: true, selector: "[showElement]", inputs: { key: ["showElement", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
204
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ShowElementDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
205
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: ShowElementDirective, isStandalone: true, selector: "[showElement]", inputs: { key: ["showElement", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
206
206
  }
207
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ShowElementDirective, decorators: [{
207
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ShowElementDirective, decorators: [{
208
208
  type: Directive,
209
209
  args: [{
210
210
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -230,10 +230,10 @@ class HideElementDirective {
230
230
  this.store.dispatchAction(new HideElementAction(elementKey));
231
231
  }
232
232
  }
233
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: HideElementDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
234
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: HideElementDirective, isStandalone: true, selector: "[hideElement]", inputs: { key: ["hideElement", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
233
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: HideElementDirective, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Directive }); }
234
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: HideElementDirective, isStandalone: true, selector: "[hideElement]", inputs: { key: ["hideElement", "key"] }, host: { listeners: { "click": "toggleElementvisibility($event)" } }, ngImport: i0 }); }
235
235
  }
236
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: HideElementDirective, decorators: [{
236
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: HideElementDirective, decorators: [{
237
237
  type: Directive,
238
238
  args: [{
239
239
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -254,10 +254,10 @@ class VisibilityToggleGroupComponent extends NgSsmComponent {
254
254
  this.items = [];
255
255
  this.hideMultipleSelectionIndicator = false;
256
256
  }
257
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: VisibilityToggleGroupComponent, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Component }); }
258
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: VisibilityToggleGroupComponent, isStandalone: true, selector: "ngssm-visibility-toggle-group", inputs: { items: "items", hideMultipleSelectionIndicator: ["hideMultipleSelectionIndicator", "hideMultipleSelectionIndicator", booleanAttribute] }, usesInheritance: true, ngImport: i0, template: "<mat-button-toggle-group [multiple]=\"true\" [hideMultipleSelectionIndicator]=\"hideMultipleSelectionIndicator\">\n <mat-button-toggle *ngFor=\"let item of items\" [toggleElementVisibility]=\"item.key\"\n [checked]=\"store.state() | isElementVisible:item.key\" [id]=\"item.key\">\n {{item.label}}\n </mat-button-toggle>\n</mat-button-toggle-group>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: i3.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled", "disabledInteractive", "hideSingleSelectionIndicator", "hideMultipleSelectionIndicator"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i3.MatButtonToggle, selector: "mat-button-toggle", inputs: ["aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "disableRipple", "appearance", "checked", "disabled", "disabledInteractive"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "directive", type: ToggleElementVisibilityDirective, selector: "[toggleElementVisibility]", inputs: ["toggleElementVisibility"] }, { kind: "pipe", type: IsElementVisiblePipe, name: "isElementVisible" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
257
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: VisibilityToggleGroupComponent, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Component }); }
258
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.4", type: VisibilityToggleGroupComponent, isStandalone: true, selector: "ngssm-visibility-toggle-group", inputs: { items: "items", hideMultipleSelectionIndicator: ["hideMultipleSelectionIndicator", "hideMultipleSelectionIndicator", booleanAttribute] }, usesInheritance: true, ngImport: i0, template: "<mat-button-toggle-group [multiple]=\"true\" [hideMultipleSelectionIndicator]=\"hideMultipleSelectionIndicator\">\n <mat-button-toggle *ngFor=\"let item of items\" [toggleElementVisibility]=\"item.key\"\n [checked]=\"store.state() | isElementVisible:item.key\" [id]=\"item.key\">\n {{item.label}}\n </mat-button-toggle>\n</mat-button-toggle-group>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: i3.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled", "disabledInteractive", "hideSingleSelectionIndicator", "hideMultipleSelectionIndicator"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i3.MatButtonToggle, selector: "mat-button-toggle", inputs: ["aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "disableRipple", "appearance", "checked", "disabled", "disabledInteractive"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "directive", type: ToggleElementVisibilityDirective, selector: "[toggleElementVisibility]", inputs: ["toggleElementVisibility"] }, { kind: "pipe", type: IsElementVisiblePipe, name: "isElementVisible" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
259
259
  }
260
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: VisibilityToggleGroupComponent, decorators: [{
260
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: VisibilityToggleGroupComponent, decorators: [{
261
261
  type: Component,
262
262
  args: [{ selector: 'ngssm-visibility-toggle-group', imports: [CommonModule, MatButtonToggleModule, ToggleElementVisibilityDirective, IsElementVisiblePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<mat-button-toggle-group [multiple]=\"true\" [hideMultipleSelectionIndicator]=\"hideMultipleSelectionIndicator\">\n <mat-button-toggle *ngFor=\"let item of items\" [toggleElementVisibility]=\"item.key\"\n [checked]=\"store.state() | isElementVisible:item.key\" [id]=\"item.key\">\n {{item.label}}\n </mat-button-toggle>\n</mat-button-toggle-group>" }]
263
263
  }], ctorParameters: () => [{ type: i1.Store }], propDecorators: { items: [{
@@ -67,10 +67,10 @@ class Logger {
67
67
  payload
68
68
  });
69
69
  }
70
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Logger, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
71
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Logger, providedIn: 'root' }); }
70
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Logger, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
71
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Logger, providedIn: 'root' }); }
72
72
  }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Logger, decorators: [{
73
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Logger, decorators: [{
74
74
  type: Injectable,
75
75
  args: [{
76
76
  providedIn: 'root'
@@ -106,10 +106,10 @@ class ConsoleAppender {
106
106
  stop() {
107
107
  this.stopEvent$.next(true);
108
108
  }
109
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ConsoleAppender, deps: [{ token: Logger }], target: i0.ɵɵFactoryTarget.Injectable }); }
110
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ConsoleAppender, providedIn: 'root' }); }
109
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ConsoleAppender, deps: [{ token: Logger }], target: i0.ɵɵFactoryTarget.Injectable }); }
110
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ConsoleAppender, providedIn: 'root' }); }
111
111
  }
112
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ConsoleAppender, decorators: [{
112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ConsoleAppender, decorators: [{
113
113
  type: Injectable,
114
114
  args: [{
115
115
  providedIn: 'root'
@@ -141,61 +141,113 @@ const NgSsmFeatureState = (specification) => {
141
141
  featureStateSpecifications.push(specification);
142
142
  };
143
143
  };
144
+ /**
145
+ * The `Store` class is a centralized state management system for Angular applications.
146
+ * It manages the application state, processes actions using reducers, and handles side effects using effects.
147
+ * The class integrates both RxJS (`BehaviorSubject`) and Angular signals for reactive state management.
148
+ *
149
+ * ### Features:
150
+ * - Centralized state management with support for reducers and effects.
151
+ * - Reactive state updates using both RxJS and Angular signals.
152
+ * - Modular initialization of feature states, reducers, and effects.
153
+ * - Sequential action processing with an action queue.
154
+ * - Logging for debugging and monitoring state changes and action processing.
155
+ *
156
+ * ### Usage:
157
+ * - Dispatch actions using `dispatchAction` or `dispatchActionType`.
158
+ * - Subscribe to state updates using `state$` (RxJS) or `state` (Angular signal).
159
+ */
144
160
  class Store {
161
+ /**
162
+ * Initializes the `Store` with reducers, effects, and state initializers.
163
+ * Also sets up the initial state and registers reducers and effects.
164
+ *
165
+ * @param logger - Logger service for debugging and monitoring.
166
+ * @param reducers - Array of reducers to process state updates.
167
+ * @param effects - Array of effects to handle side effects.
168
+ * @param initializers - Array of state initializers to set up the initial state.
169
+ * @param injector - Angular's `EnvironmentInjector` for running effects in the correct context.
170
+ */
145
171
  constructor(logger, reducers, effects, initializers, injector) {
146
172
  this.logger = logger;
147
173
  this.injector = injector;
174
+ // The current state of the application, managed as a BehaviorSubject for RxJS compatibility.
148
175
  this._state$ = new BehaviorSubject({});
176
+ // A queue to ensure actions are processed sequentially.
149
177
  this.actionQueue = [];
178
+ // Maps action types to their corresponding reducers.
150
179
  this.reducersPerActionType = new Map();
180
+ // Maps action types to their corresponding effects.
151
181
  this.effectsPerActionType = new Map();
182
+ // The current state of the application, managed as an Angular signal for signal-based reactivity.
152
183
  this._stateSignal = signal({});
184
+ // The most recently action processed by reducers, managed as an Angular signal.
185
+ this._processedAction = signal({});
186
+ // Synchronize the RxJS state with the Angular signal state.
153
187
  this._state$.subscribe((value) => this._stateSignal.set(value));
154
188
  this.logger.information('[Store] ---> state initialization...');
155
189
  let state = this._state$.getValue();
190
+ // Initialize feature states.
156
191
  state = featureStateSpecifications.reduce((p, c) => update(p, { [c.featureStateKey]: { $set: c.initialState } }), state);
192
+ // Apply state initializers.
157
193
  (initializers ?? []).forEach((initializer) => {
158
194
  this.logger.information('[Store] ------> calling initializer', initializer);
159
195
  state = initializer.initializeState(state);
160
196
  });
197
+ // Update the state with the initialized values.
161
198
  this._state$.next(state);
199
+ // Register reducers and effects.
162
200
  this.logger.information(`[Store] ---> initialization of ${(reducers ?? []).length} reducers...`);
163
- (reducers ?? []).forEach((reducer) => {
164
- this.logger.information('[Store] ------> initialization of ', reducer);
165
- reducer.processedActions.forEach((processedAction) => {
166
- const storeReducers = this.reducersPerActionType.get(processedAction) ?? [];
167
- if (storeReducers.length === 0) {
168
- this.reducersPerActionType.set(processedAction, storeReducers);
169
- }
170
- storeReducers.push(reducer);
171
- });
172
- });
201
+ this.initializeProcessors(reducers, this.reducersPerActionType, (r) => r.processedActions);
173
202
  this.logger.information(`[Store] ---> initialization of ${(effects ?? []).length} effects...`);
174
- (effects ?? []).forEach((effect) => {
175
- this.logger.information('[Store] ------> initialization of ', effect);
176
- effect.processedActions.forEach((processedAction) => {
177
- const storedEffects = this.effectsPerActionType.get(processedAction) ?? [];
178
- if (storedEffects.length === 0) {
179
- this.effectsPerActionType.set(processedAction, storedEffects);
180
- }
181
- storedEffects.push(effect);
182
- });
183
- });
203
+ this.initializeProcessors(effects, this.effectsPerActionType, (e) => e.processedActions);
184
204
  }
205
+ /**
206
+ * Returns the current state as an RxJS observable.
207
+ * Useful for subscribing to state changes in a reactive manner.
208
+ */
185
209
  get state$() {
186
210
  return this._state$.asObservable();
187
211
  }
212
+ /**
213
+ * Returns the most recently action processed by reducers as an Angular signal.
214
+ * Useful for accessing the last processed action in a reactive manner.
215
+ * This signal is updated before processing the effects.
216
+ */
217
+ get processedAction() {
218
+ return this._processedAction.asReadonly();
219
+ }
220
+ /**
221
+ * Returns the current state as an Angular signal.
222
+ * Useful for signal-based reactivity in Angular components.
223
+ */
188
224
  get state() {
189
225
  return this._stateSignal.asReadonly();
190
226
  }
227
+ /**
228
+ * Dispatches an action to the store.
229
+ * The action is added to the action queue and processed sequentially.
230
+ *
231
+ * @param action - The action to dispatch.
232
+ */
191
233
  dispatchAction(action) {
192
234
  this.actionQueue.push(action);
193
235
  this.logger.debug(`Action of type '${action.type}' added to the queue => ${this.actionQueue.length} pending actions`, action);
194
- setTimeout(() => this.processNextAction());
236
+ Promise.resolve().then(() => this.processNextAction());
195
237
  }
238
+ /**
239
+ * Dispatches an action by its type.
240
+ * This is a shorthand for dispatching actions without additional payload.
241
+ *
242
+ * @param type - The type of the action to dispatch.
243
+ */
196
244
  dispatchActionType(type) {
197
245
  this.dispatchAction({ type });
198
246
  }
247
+ /**
248
+ * Processes the next action in the action queue.
249
+ * Applies reducers to update the state and executes effects for side effects.
250
+ */
199
251
  processNextAction() {
200
252
  const nextAction = this.actionQueue.shift();
201
253
  if (!nextAction) {
@@ -204,13 +256,9 @@ class Store {
204
256
  }
205
257
  this.logger.information(`[processNextAction] Start processing action '${nextAction.type}...`, nextAction);
206
258
  try {
207
- const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];
208
- this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);
209
- const currentState = this._state$.getValue();
210
- const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);
211
- if (updatedState !== currentState) {
212
- this._state$.next(updatedState);
213
- }
259
+ // Apply reducers to update the state.
260
+ const updatedState = this.applyReducers(nextAction);
261
+ // Execute effects for the action.
214
262
  const effects = this.effectsPerActionType.get(nextAction.type) ?? [];
215
263
  this.logger.debug(`[Store] ${effects.length} effects found to process the action ${nextAction.type}`, effects);
216
264
  effects.forEach((effect) => {
@@ -230,10 +278,40 @@ class Store {
230
278
  }
231
279
  finally {
232
280
  this.logger.information(`[processNextAction] action '${nextAction.type} processed.`, nextAction);
233
- // Should not be useful.But, just in case.
234
- setTimeout(() => this.processNextAction());
281
+ // Process the next action asynchronously.
282
+ Promise.resolve().then(() => this.processNextAction());
235
283
  }
236
284
  }
285
+ /**
286
+ * Applies reducers to the current state based on the dispatched action.
287
+ * Updates the state if there are changes and sets the processed action signal.
288
+ *
289
+ * @param nextAction - The action being processed.
290
+ * @returns The updated state after applying reducers.
291
+ */
292
+ applyReducers(nextAction) {
293
+ try {
294
+ const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];
295
+ this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);
296
+ const currentState = this._state$.getValue();
297
+ const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);
298
+ if (updatedState !== currentState) {
299
+ this._state$.next(updatedState);
300
+ }
301
+ return updatedState;
302
+ }
303
+ finally {
304
+ this._processedAction.set(nextAction); // Update the processed action signal.
305
+ }
306
+ }
307
+ /**
308
+ * Executes an effect for a given action.
309
+ * Handles any errors that occur during effect execution.
310
+ *
311
+ * @param effect - The effect to execute.
312
+ * @param updatedState - The updated state after reducers have been applied.
313
+ * @param nextAction - The action being processed.
314
+ */
237
315
  runEffect(effect, updatedState, nextAction) {
238
316
  try {
239
317
  effect.processAction(this, updatedState, nextAction);
@@ -246,10 +324,29 @@ class Store {
246
324
  });
247
325
  }
248
326
  }
249
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Store, deps: [{ token: Logger }, { token: NGSSM_REDUCER, optional: true }, { token: NGSSM_EFFECT, optional: true }, { token: NGSSM_STATE_INITIALIZER, optional: true }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
250
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Store, providedIn: 'root' }); }
327
+ /**
328
+ * Initializes reducers or effects and maps them to their corresponding action types.
329
+ *
330
+ * @param processors - The array of reducers or effects to initialize.
331
+ * @param processorMap - The map to store processors by action type.
332
+ * @param getProcessedActions - A function to retrieve the action types processed by a processor.
333
+ */
334
+ initializeProcessors(processors, processorMap, getProcessedActions) {
335
+ (processors ?? []).forEach((processor) => {
336
+ this.logger.information('[Store] ------> initialization of ', processor);
337
+ getProcessedActions(processor).forEach((actionType) => {
338
+ const storedProcessors = processorMap.get(actionType) ?? [];
339
+ if (storedProcessors.length === 0) {
340
+ processorMap.set(actionType, storedProcessors);
341
+ }
342
+ storedProcessors.push(processor);
343
+ });
344
+ });
345
+ }
346
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Store, deps: [{ token: Logger }, { token: NGSSM_REDUCER, optional: true }, { token: NGSSM_EFFECT, optional: true }, { token: NGSSM_STATE_INITIALIZER, optional: true }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
347
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Store, providedIn: 'root' }); }
251
348
  }
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Store, decorators: [{
349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: Store, decorators: [{
253
350
  type: Injectable,
254
351
  args: [{
255
352
  providedIn: 'root'
@@ -317,10 +414,10 @@ class ProvideNgssmFeatureStateDirective {
317
414
  ngOnDestroy() {
318
415
  this.store.dispatchAction(new NgssmUnregisterFeatureStateAction(this.component.featureStateKey));
319
416
  }
320
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ProvideNgssmFeatureStateDirective, deps: [{ token: NGSSM_COMPONENT_WITH_FEATURE_STATE }, { token: Store }], target: i0.ɵɵFactoryTarget.Directive }); }
321
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: ProvideNgssmFeatureStateDirective, isStandalone: true, selector: "[provideNgssmFeatureState]", ngImport: i0 }); }
417
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ProvideNgssmFeatureStateDirective, deps: [{ token: NGSSM_COMPONENT_WITH_FEATURE_STATE }, { token: Store }], target: i0.ɵɵFactoryTarget.Directive }); }
418
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: ProvideNgssmFeatureStateDirective, isStandalone: true, selector: "[provideNgssmFeatureState]", ngImport: i0 }); }
322
419
  }
323
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: ProvideNgssmFeatureStateDirective, decorators: [{
420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: ProvideNgssmFeatureStateDirective, decorators: [{
324
421
  type: Directive,
325
422
  args: [{
326
423
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -353,10 +450,10 @@ class FeatureStateReducer {
353
450
  }
354
451
  return state;
355
452
  }
356
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: FeatureStateReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
357
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: FeatureStateReducer }); }
453
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: FeatureStateReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
454
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: FeatureStateReducer }); }
358
455
  }
359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: FeatureStateReducer, decorators: [{
456
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: FeatureStateReducer, decorators: [{
360
457
  type: Injectable
361
458
  }] });
362
459
 
@@ -381,10 +478,10 @@ class NgSsmComponent {
381
478
  dispatchActionType(actionType) {
382
479
  this.store.dispatchActionType(actionType);
383
480
  }
384
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NgSsmComponent, deps: [{ token: Store }], target: i0.ɵɵFactoryTarget.Directive }); }
385
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: NgSsmComponent, isStandalone: true, ngImport: i0 }); }
481
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: NgSsmComponent, deps: [{ token: Store }], target: i0.ɵɵFactoryTarget.Directive }); }
482
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: NgSsmComponent, isStandalone: true, ngImport: i0 }); }
386
483
  }
387
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NgSsmComponent, decorators: [{
484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: NgSsmComponent, decorators: [{
388
485
  type: Directive,
389
486
  args: [{}]
390
487
  }], ctorParameters: () => [{ type: Store }] });
@@ -1 +1 @@
1
- {"version":3,"file":"ngssm-store.mjs","sources":["../../../projects/ngssm-store/src/lib/reducer.ts","../../../projects/ngssm-store/src/lib/effect.ts","../../../projects/ngssm-store/src/lib/state-initializer.ts","../../../projects/ngssm-store/src/lib/logging/log-level.ts","../../../projects/ngssm-store/src/lib/logging/logger.ts","../../../projects/ngssm-store/src/lib/logging/console-appender.ts","../../../projects/ngssm-store/src/lib/logging/provide-console-appender.ts","../../../projects/ngssm-store/src/lib/store.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state-specification.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-store-action-type.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-register-feature-state.action.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-unregister-feature-state.action.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-feature-state.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-ngssm-feature-state.directive.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state.reducer.ts","../../../projects/ngssm-store/src/lib/ngssm-component.ts","../../../projects/ngssm-store/src/lib/provide-ngssm-store.ts","../../../projects/ngssm-store/src/lib/signal-helpers.ts","../../../projects/ngssm-store/src/public-api.ts","../../../projects/ngssm-store/src/ngssm-store.ts"],"sourcesContent":["import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\n\nexport interface Reducer {\n processedActions: string[];\n updateState(state: State, action: Action): State;\n}\n\nexport const NGSSM_REDUCER = new InjectionToken<Reducer>('NGSSM_REDUCER');\n\nexport const provideReducer = (reducer: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_REDUCER, useClass: reducer, multi: true }]);\n};\n\nexport const provideReducers = (...reducers: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(reducers.map((reducer) => ({ provide: NGSSM_REDUCER, useClass: reducer, multi: true })));\n};\n","import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { ActionDispatcher } from './action-dispatcher';\n\nexport interface Effect {\n processedActions: string[];\n processAction(actiondispatcher: ActionDispatcher, state: State, action: Action): void;\n isFunc?: boolean;\n}\n\nexport const NGSSM_EFFECT = new InjectionToken<Effect>('NGSSM_EFFECT');\n\nexport const provideEffect = (effect: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_EFFECT, useClass: effect, multi: true }]);\n};\n\nexport const provideEffects = (...effects: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(effects.map((effect) => ({ provide: NGSSM_EFFECT, useClass: effect, multi: true })));\n};\n\nexport type EffectFunc = (state: State, action: Action) => void;\n\nexport const provideEffectFunc = (actionType: string, effectFunc: EffectFunc): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_EFFECT,\n useFactory: () => {\n const effect: Effect = {\n processedActions: [actionType],\n processAction: (_, state, action) => effectFunc(state, action),\n isFunc: true\n };\n return effect;\n },\n multi: true\n }\n ]);\n};\n","import { InjectionToken } from '@angular/core';\nimport { State } from './state';\n\nexport interface StateInitializer {\n initializeState(state: State): State;\n}\n\nexport const NGSSM_STATE_INITIALIZER = new InjectionToken<StateInitializer>('NGSSM_STATE_INITIALIZER');\n","export enum LogLevel {\n debug = 'Debug',\n information = 'Information',\n error = 'Error'\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport { LogEvent } from './log-event';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Logger {\n private readonly _logEvents$ = new Subject<LogEvent>();\n\n public get logEvents$(): Observable<LogEvent> {\n return this._logEvents$.asObservable();\n }\n\n public debug(message: string, payload?: unknown): void {\n this.log(LogLevel.debug, message, payload);\n }\n\n public information(message: string, payload?: unknown): void {\n this.log(LogLevel.information, message, payload);\n }\n\n public error(message: string, payload?: unknown): void {\n this.log(LogLevel.error, message, payload);\n }\n\n public log(level: LogLevel, message: string, payload?: unknown): void {\n this._logEvents$.next({\n level,\n message,\n payload\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { Logger } from './logger';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConsoleAppender {\n private readonly stopEvent$ = new Subject<boolean>();\n\n constructor(private logger: Logger) {}\n\n public start(contextName?: string): void {\n this.logger.logEvents$.pipe(takeUntil(this.stopEvent$)).subscribe((logEvent) => {\n let logFunction: (...data:unknown[])=> void;\n switch (logEvent.level) {\n case LogLevel.error:\n logFunction = console.error;\n break;\n\n default:\n logFunction = console.log;\n break;\n }\n\n const now = new Date().toLocaleString();\n const prefix = contextName ? `[${contextName}] ` : '';\n\n if (logEvent.payload) {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`, logEvent.payload);\n } else {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`);\n }\n });\n }\n\n public stop(): void {\n this.stopEvent$.next(true);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { ConsoleAppender } from './console-appender';\n\nexport const NGSSM_CONSOLE_APPENDER_NAME = new InjectionToken<string>('NGSSM_CONSOLE_APPENDER_NAME');\n\nexport const startConsoleAppenderFactory = (): (() => void) => {\n return () => {\n const name = inject(NGSSM_CONSOLE_APPENDER_NAME);\n const consoleAppender = inject(ConsoleAppender);\n consoleAppender.start(name);\n };\n};\n\nexport const provideConsoleAppender = (name: string): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_CONSOLE_APPENDER_NAME,\n useValue: name\n },\n provideAppInitializer(startConsoleAppenderFactory())\n ]);\n};\n","import { EnvironmentInjector, Inject, Injectable, Optional, Signal, runInInjectionContext, signal } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\nimport update from 'immutability-helper';\n\nimport { FeatureStateSpecification } from './feature-state';\nimport { State } from './state';\nimport { Action } from './action';\nimport { NGSSM_REDUCER, Reducer } from './reducer';\nimport { Effect, NGSSM_EFFECT } from './effect';\nimport { NGSSM_STATE_INITIALIZER, StateInitializer } from './state-initializer';\nimport { Logger } from './logging';\nimport { ActionDispatcher } from './action-dispatcher';\n\nconst featureStateSpecifications: FeatureStateSpecification[] = [];\nexport const NgSsmFeatureState = (specification: FeatureStateSpecification) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (target: object) => {\n featureStateSpecifications.push(specification);\n };\n};\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Store implements ActionDispatcher {\n private readonly _state$ = new BehaviorSubject<State>({});\n private readonly actionQueue: Action[] = [];\n private readonly reducersPerActionType = new Map<string, Reducer[]>();\n private readonly effectsPerActionType = new Map<string, Effect[]>();\n private readonly _stateSignal = signal<State>({});\n\n constructor(\n private logger: Logger,\n @Inject(NGSSM_REDUCER) @Optional() reducers: Reducer[],\n @Inject(NGSSM_EFFECT) @Optional() effects: Effect[],\n @Inject(NGSSM_STATE_INITIALIZER) @Optional() initializers: StateInitializer[],\n private injector: EnvironmentInjector\n ) {\n this._state$.subscribe((value) => this._stateSignal.set(value));\n this.logger.information('[Store] ---> state initialization...');\n let state = this._state$.getValue();\n state = featureStateSpecifications.reduce((p, c) => update(p, { [c.featureStateKey]: { $set: c.initialState } }), state);\n\n (initializers ?? []).forEach((initializer) => {\n this.logger.information('[Store] ------> calling initializer', initializer);\n state = initializer.initializeState(state);\n });\n\n this._state$.next(state);\n\n this.logger.information(`[Store] ---> initialization of ${(reducers ?? []).length} reducers...`);\n (reducers ?? []).forEach((reducer) => {\n this.logger.information('[Store] ------> initialization of ', reducer);\n reducer.processedActions.forEach((processedAction) => {\n const storeReducers: Reducer[] = this.reducersPerActionType.get(processedAction) ?? [];\n if (storeReducers.length === 0) {\n this.reducersPerActionType.set(processedAction, storeReducers);\n }\n\n storeReducers.push(reducer);\n });\n });\n\n this.logger.information(`[Store] ---> initialization of ${(effects ?? []).length} effects...`);\n (effects ?? []).forEach((effect) => {\n this.logger.information('[Store] ------> initialization of ', effect);\n effect.processedActions.forEach((processedAction) => {\n const storedEffects: Effect[] = this.effectsPerActionType.get(processedAction) ?? [];\n if (storedEffects.length === 0) {\n this.effectsPerActionType.set(processedAction, storedEffects);\n }\n\n storedEffects.push(effect);\n });\n });\n }\n\n public get state$(): Observable<State> {\n return this._state$.asObservable();\n }\n\n public get state(): Signal<State> {\n return this._stateSignal.asReadonly();\n }\n\n public dispatchAction(action: Action): void {\n this.actionQueue.push(action);\n this.logger.debug(`Action of type '${action.type}' added to the queue => ${this.actionQueue.length} pending actions`, action);\n setTimeout(() => this.processNextAction());\n }\n\n public dispatchActionType(type: string): void {\n this.dispatchAction({ type });\n }\n\n private processNextAction(): void {\n const nextAction = this.actionQueue.shift();\n if (!nextAction) {\n this.logger.debug('[processNextAction] No action to process');\n return;\n }\n\n this.logger.information(`[processNextAction] Start processing action '${nextAction.type}...`, nextAction);\n\n try {\n const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);\n const currentState = this._state$.getValue();\n const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);\n\n if (updatedState !== currentState) {\n this._state$.next(updatedState);\n }\n\n const effects = this.effectsPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${effects.length} effects found to process the action ${nextAction.type}`, effects);\n effects.forEach((effect) => {\n if (effect.isFunc === true) {\n runInInjectionContext(this.injector, () => this.runEffect(effect, updatedState, nextAction));\n } else {\n this.runEffect(effect, updatedState, nextAction);\n }\n });\n } catch (error) {\n this.logger.error(`Error when processing action ${nextAction.type}`, {\n error,\n action: nextAction\n });\n } finally {\n this.logger.information(`[processNextAction] action '${nextAction.type} processed.`, nextAction);\n\n // Should not be useful.But, just in case.\n setTimeout(() => this.processNextAction());\n }\n }\n\n private runEffect(effect: Effect, updatedState: State, nextAction: Action) {\n try {\n effect.processAction(this, updatedState, nextAction);\n } catch (error) {\n this.logger.error(`Unable to process action ${nextAction.type} by effect ${effect}`, {\n error,\n action: nextAction,\n processor: effect\n });\n }\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface FeatureStateSpecification {\n readonly featureStateKey: string;\n readonly initialState: object;\n}\n\nexport const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<FeatureStateSpecification>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n","export enum NgssmStoreActionType {\n registerFeatureState = '[NgssmStoreActionType] registerFeatureState',\n unregisterFeatureState = '[NgssmStoreActionType] unregisterFeatureState'\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmRegisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.registerFeatureState;\n\n constructor(\n public readonly featureStateKey: string,\n public readonly initialValue: object\n ) {}\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmUnregisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.unregisterFeatureState;\n\n constructor(public readonly featureStateKey: string) {}\n}\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction } from '../actions';\n\nconst registerFeatureState = (featureStateKey: string, initialValue: object) => {\n return () => {\n inject(Store).dispatchAction(new NgssmRegisterFeatureStateAction(featureStateKey, initialValue));\n };\n};\n\nexport const provideNgssmFeatureState = (featureStateKey: string, initialValue: object): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(registerFeatureState(featureStateKey, initialValue))]);\n};\n","import { Directive, Inject, OnDestroy } from '@angular/core';\n\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { FeatureStateSpecification, NGSSM_COMPONENT_WITH_FEATURE_STATE } from './feature-state-specification';\n\n// export interface ComponentWithFeatureState {\n// featureStateKey: string;\n// initialValue: object;\n// }\n\n// export const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<ComponentWithFeatureState>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[provideNgssmFeatureState]',\n standalone: true\n})\nexport class ProvideNgssmFeatureStateDirective implements OnDestroy {\n constructor(\n @Inject(NGSSM_COMPONENT_WITH_FEATURE_STATE) private component: FeatureStateSpecification,\n private store: Store\n ) {\n this.store.dispatchAction(new NgssmRegisterFeatureStateAction(this.component.featureStateKey, this.component.initialState));\n }\n\n public ngOnDestroy(): void {\n this.store.dispatchAction(new NgssmUnregisterFeatureStateAction(this.component.featureStateKey));\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport update from 'immutability-helper';\n\nimport { Reducer } from '../reducer';\nimport { NgssmRegisterFeatureStateAction, NgssmStoreActionType, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { State } from '../state';\nimport { Action } from '../action';\n\n@Injectable()\nexport class FeatureStateReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmStoreActionType.registerFeatureState, NgssmStoreActionType.unregisterFeatureState];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmStoreActionType.registerFeatureState: {\n const registerFeatureStateAction = action as NgssmRegisterFeatureStateAction;\n return update(state, {\n [registerFeatureStateAction.featureStateKey]: { $set: registerFeatureStateAction.initialValue }\n });\n }\n\n case NgssmStoreActionType.unregisterFeatureState: {\n const unregisterFeatureStateAction = action as NgssmUnregisterFeatureStateAction;\n return update(state, {\n $unset: [unregisterFeatureStateAction.featureStateKey]\n });\n }\n }\n\n return state;\n }\n}\n","import { Directive, OnDestroy } from '@angular/core';\nimport { map, Observable, Subject, distinctUntilChanged, takeUntil } from 'rxjs';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { Store } from './store';\n\n@Directive({\n})\nexport class NgSsmComponent implements OnDestroy {\n private readonly _unsubscribeAll$ = new Subject<void>();\n\n constructor(protected store: Store) {}\n\n protected get unsubscribeAll$(): Observable<void> {\n return this._unsubscribeAll$.asObservable();\n }\n\n public ngOnDestroy(): void {\n this._unsubscribeAll$.next();\n this._unsubscribeAll$.complete();\n }\n\n public watch<T>(selector: (state: State) => T): Observable<T> {\n return this.store.state$.pipe(\n map((state) => selector(state)),\n distinctUntilChanged(),\n takeUntil(this.unsubscribeAll$)\n );\n }\n\n public dispatchAction(action: Action): void {\n this.store.dispatchAction(action);\n }\n\n public dispatchActionType(actionType: string): void {\n this.store.dispatchActionType(actionType);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport { provideReducers } from './reducer';\nimport { ActionDispatcher } from './action-dispatcher';\nimport { FeatureStateReducer } from './feature-state';\nimport { Store } from './store';\n\nexport const ACTION_DISPATCHER = new InjectionToken<ActionDispatcher>('ACTION_DISPATCHER');\n\nexport const provideNgssmStore = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(FeatureStateReducer), { provide: ACTION_DISPATCHER, useExisting: Store }]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { State } from './state';\nimport { Store } from './store';\n\nexport const createSignal = <T = unknown>(selector: (state: State) => T): Signal<T> => {\n const store = inject(Store);\n return computed(() => selector(store.state()));\n};\n","/*\n * Public API Surface of ngssm-store\n */\n\nexport * from './lib/store';\nexport * from './lib/state';\nexport * from './lib/action';\nexport * from './lib/reducer';\nexport * from './lib/effect';\nexport * from './lib/feature-state';\nexport * from './lib/ngssm-component';\nexport * from './lib/state-initializer';\nexport * from './lib/logging';\nexport * from './lib/actions';\nexport * from './lib/provide-ngssm-store';\nexport * from './lib/signal-helpers';\nexport * from './lib/action-dispatcher';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.Logger","i1.Store"],"mappings":";;;;;MAUa,aAAa,GAAG,IAAI,cAAc,CAAU,eAAe;AAE3D,MAAA,cAAc,GAAG,CAAC,OAAsB,KAA0B;AAC7E,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/F;MAEa,eAAe,GAAG,CAAC,GAAG,QAAyB,KAA0B;AACpF,IAAA,OAAO,wBAAwB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,MA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A,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAF1B,SAAS;mBAAC,EACV;;;MCDY,iBAAiB,GAAG,IAAI,cAAc,CAAmB,mBAAmB;AAElF,MAAM,iBAAiB,GAAG,MAA2B;AAC1D,IAAA,OAAO,wBAAwB,CAAC,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7H;;ACPa,MAAA,YAAY,GAAG,CAAc,QAA6B,KAAe;AACpF,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAC3B,IAAA,OAAO,QAAQ,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;AAChD;;ACPA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngssm-store.mjs","sources":["../../../projects/ngssm-store/src/lib/reducer.ts","../../../projects/ngssm-store/src/lib/effect.ts","../../../projects/ngssm-store/src/lib/state-initializer.ts","../../../projects/ngssm-store/src/lib/logging/log-level.ts","../../../projects/ngssm-store/src/lib/logging/logger.ts","../../../projects/ngssm-store/src/lib/logging/console-appender.ts","../../../projects/ngssm-store/src/lib/logging/provide-console-appender.ts","../../../projects/ngssm-store/src/lib/store.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state-specification.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-store-action-type.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-register-feature-state.action.ts","../../../projects/ngssm-store/src/lib/actions/ngssm-unregister-feature-state.action.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-feature-state.ts","../../../projects/ngssm-store/src/lib/feature-state/provide-ngssm-feature-state.directive.ts","../../../projects/ngssm-store/src/lib/feature-state/feature-state.reducer.ts","../../../projects/ngssm-store/src/lib/ngssm-component.ts","../../../projects/ngssm-store/src/lib/provide-ngssm-store.ts","../../../projects/ngssm-store/src/lib/signal-helpers.ts","../../../projects/ngssm-store/src/public-api.ts","../../../projects/ngssm-store/src/ngssm-store.ts"],"sourcesContent":["import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\n\nexport interface Reducer {\n processedActions: string[];\n updateState(state: State, action: Action): State;\n}\n\nexport const NGSSM_REDUCER = new InjectionToken<Reducer>('NGSSM_REDUCER');\n\nexport const provideReducer = (reducer: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_REDUCER, useClass: reducer, multi: true }]);\n};\n\nexport const provideReducers = (...reducers: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(reducers.map((reducer) => ({ provide: NGSSM_REDUCER, useClass: reducer, multi: true })));\n};\n","import { EnvironmentProviders, InjectionToken, Type, makeEnvironmentProviders } from '@angular/core';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { ActionDispatcher } from './action-dispatcher';\n\nexport interface Effect {\n processedActions: string[];\n processAction(actiondispatcher: ActionDispatcher, state: State, action: Action): void;\n isFunc?: boolean;\n}\n\nexport const NGSSM_EFFECT = new InjectionToken<Effect>('NGSSM_EFFECT');\n\nexport const provideEffect = (effect: Type<unknown>): EnvironmentProviders => {\n return makeEnvironmentProviders([{ provide: NGSSM_EFFECT, useClass: effect, multi: true }]);\n};\n\nexport const provideEffects = (...effects: Type<unknown>[]): EnvironmentProviders => {\n return makeEnvironmentProviders(effects.map((effect) => ({ provide: NGSSM_EFFECT, useClass: effect, multi: true })));\n};\n\nexport type EffectFunc = (state: State, action: Action) => void;\n\nexport const provideEffectFunc = (actionType: string, effectFunc: EffectFunc): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_EFFECT,\n useFactory: () => {\n const effect: Effect = {\n processedActions: [actionType],\n processAction: (_, state, action) => effectFunc(state, action),\n isFunc: true\n };\n return effect;\n },\n multi: true\n }\n ]);\n};\n","import { InjectionToken } from '@angular/core';\nimport { State } from './state';\n\nexport interface StateInitializer {\n initializeState(state: State): State;\n}\n\nexport const NGSSM_STATE_INITIALIZER = new InjectionToken<StateInitializer>('NGSSM_STATE_INITIALIZER');\n","export enum LogLevel {\n debug = 'Debug',\n information = 'Information',\n error = 'Error'\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport { LogEvent } from './log-event';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Logger {\n private readonly _logEvents$ = new Subject<LogEvent>();\n\n public get logEvents$(): Observable<LogEvent> {\n return this._logEvents$.asObservable();\n }\n\n public debug(message: string, payload?: unknown): void {\n this.log(LogLevel.debug, message, payload);\n }\n\n public information(message: string, payload?: unknown): void {\n this.log(LogLevel.information, message, payload);\n }\n\n public error(message: string, payload?: unknown): void {\n this.log(LogLevel.error, message, payload);\n }\n\n public log(level: LogLevel, message: string, payload?: unknown): void {\n this._logEvents$.next({\n level,\n message,\n payload\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { Logger } from './logger';\nimport { LogLevel } from './log-level';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConsoleAppender {\n private readonly stopEvent$ = new Subject<boolean>();\n\n constructor(private logger: Logger) {}\n\n public start(contextName?: string): void {\n this.logger.logEvents$.pipe(takeUntil(this.stopEvent$)).subscribe((logEvent) => {\n let logFunction: (...data:unknown[])=> void;\n switch (logEvent.level) {\n case LogLevel.error:\n logFunction = console.error;\n break;\n\n default:\n logFunction = console.log;\n break;\n }\n\n const now = new Date().toLocaleString();\n const prefix = contextName ? `[${contextName}] ` : '';\n\n if (logEvent.payload) {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`, logEvent.payload);\n } else {\n logFunction(`${prefix}[${now}] [${logEvent.level}] ${logEvent.message}`);\n }\n });\n }\n\n public stop(): void {\n this.stopEvent$.next(true);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { ConsoleAppender } from './console-appender';\n\nexport const NGSSM_CONSOLE_APPENDER_NAME = new InjectionToken<string>('NGSSM_CONSOLE_APPENDER_NAME');\n\nexport const startConsoleAppenderFactory = (): (() => void) => {\n return () => {\n const name = inject(NGSSM_CONSOLE_APPENDER_NAME);\n const consoleAppender = inject(ConsoleAppender);\n consoleAppender.start(name);\n };\n};\n\nexport const provideConsoleAppender = (name: string): EnvironmentProviders => {\n return makeEnvironmentProviders([\n {\n provide: NGSSM_CONSOLE_APPENDER_NAME,\n useValue: name\n },\n provideAppInitializer(startConsoleAppenderFactory())\n ]);\n};\n","import { EnvironmentInjector, Inject, Injectable, Optional, Signal, runInInjectionContext, signal } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\nimport update from 'immutability-helper';\n\nimport { FeatureStateSpecification } from './feature-state';\nimport { State } from './state';\nimport { Action } from './action';\nimport { NGSSM_REDUCER, Reducer } from './reducer';\nimport { Effect, NGSSM_EFFECT } from './effect';\nimport { NGSSM_STATE_INITIALIZER, StateInitializer } from './state-initializer';\nimport { Logger } from './logging';\nimport { ActionDispatcher } from './action-dispatcher';\n\nconst featureStateSpecifications: FeatureStateSpecification[] = [];\nexport const NgSsmFeatureState = (specification: FeatureStateSpecification) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (target: object) => {\n featureStateSpecifications.push(specification);\n };\n};\n\n/**\n * The `Store` class is a centralized state management system for Angular applications.\n * It manages the application state, processes actions using reducers, and handles side effects using effects.\n * The class integrates both RxJS (`BehaviorSubject`) and Angular signals for reactive state management.\n *\n * ### Features:\n * - Centralized state management with support for reducers and effects.\n * - Reactive state updates using both RxJS and Angular signals.\n * - Modular initialization of feature states, reducers, and effects.\n * - Sequential action processing with an action queue.\n * - Logging for debugging and monitoring state changes and action processing.\n *\n * ### Usage:\n * - Dispatch actions using `dispatchAction` or `dispatchActionType`.\n * - Subscribe to state updates using `state$` (RxJS) or `state` (Angular signal).\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class Store implements ActionDispatcher {\n // The current state of the application, managed as a BehaviorSubject for RxJS compatibility.\n private readonly _state$ = new BehaviorSubject<State>({});\n\n // A queue to ensure actions are processed sequentially.\n private readonly actionQueue: Action[] = [];\n\n // Maps action types to their corresponding reducers.\n private readonly reducersPerActionType = new Map<string, Reducer[]>();\n\n // Maps action types to their corresponding effects.\n private readonly effectsPerActionType = new Map<string, Effect[]>();\n\n // The current state of the application, managed as an Angular signal for signal-based reactivity.\n private readonly _stateSignal = signal<State>({});\n\n // The most recently action processed by reducers, managed as an Angular signal.\n private readonly _processedAction = signal<Action>({} as Action);\n\n /**\n * Initializes the `Store` with reducers, effects, and state initializers.\n * Also sets up the initial state and registers reducers and effects.\n *\n * @param logger - Logger service for debugging and monitoring.\n * @param reducers - Array of reducers to process state updates.\n * @param effects - Array of effects to handle side effects.\n * @param initializers - Array of state initializers to set up the initial state.\n * @param injector - Angular's `EnvironmentInjector` for running effects in the correct context.\n */\n constructor(\n private logger: Logger,\n @Inject(NGSSM_REDUCER) @Optional() reducers: Reducer[],\n @Inject(NGSSM_EFFECT) @Optional() effects: Effect[],\n @Inject(NGSSM_STATE_INITIALIZER) @Optional() initializers: StateInitializer[],\n private injector: EnvironmentInjector\n ) {\n // Synchronize the RxJS state with the Angular signal state.\n this._state$.subscribe((value) => this._stateSignal.set(value));\n\n this.logger.information('[Store] ---> state initialization...');\n let state = this._state$.getValue();\n\n // Initialize feature states.\n state = featureStateSpecifications.reduce((p, c) => update(p, { [c.featureStateKey]: { $set: c.initialState } }), state);\n\n // Apply state initializers.\n (initializers ?? []).forEach((initializer) => {\n this.logger.information('[Store] ------> calling initializer', initializer);\n state = initializer.initializeState(state);\n });\n\n // Update the state with the initialized values.\n this._state$.next(state);\n\n // Register reducers and effects.\n this.logger.information(`[Store] ---> initialization of ${(reducers ?? []).length} reducers...`);\n this.initializeProcessors(reducers, this.reducersPerActionType, (r) => r.processedActions);\n this.logger.information(`[Store] ---> initialization of ${(effects ?? []).length} effects...`);\n this.initializeProcessors(effects, this.effectsPerActionType, (e) => e.processedActions);\n }\n\n /**\n * Returns the current state as an RxJS observable.\n * Useful for subscribing to state changes in a reactive manner.\n */\n public get state$(): Observable<State> {\n return this._state$.asObservable();\n }\n\n /**\n * Returns the most recently action processed by reducers as an Angular signal.\n * Useful for accessing the last processed action in a reactive manner.\n * This signal is updated before processing the effects.\n */\n public get processedAction(): Signal<Action> {\n return this._processedAction.asReadonly();\n }\n\n /**\n * Returns the current state as an Angular signal.\n * Useful for signal-based reactivity in Angular components.\n */\n public get state(): Signal<State> {\n return this._stateSignal.asReadonly();\n }\n\n /**\n * Dispatches an action to the store.\n * The action is added to the action queue and processed sequentially.\n *\n * @param action - The action to dispatch.\n */\n public dispatchAction(action: Action): void {\n this.actionQueue.push(action);\n this.logger.debug(`Action of type '${action.type}' added to the queue => ${this.actionQueue.length} pending actions`, action);\n Promise.resolve().then(() => this.processNextAction());\n }\n\n /**\n * Dispatches an action by its type.\n * This is a shorthand for dispatching actions without additional payload.\n *\n * @param type - The type of the action to dispatch.\n */\n public dispatchActionType(type: string): void {\n this.dispatchAction({ type });\n }\n\n /**\n * Processes the next action in the action queue.\n * Applies reducers to update the state and executes effects for side effects.\n */\n private processNextAction(): void {\n const nextAction = this.actionQueue.shift();\n if (!nextAction) {\n this.logger.debug('[processNextAction] No action to process');\n return;\n }\n\n this.logger.information(`[processNextAction] Start processing action '${nextAction.type}...`, nextAction);\n\n try {\n // Apply reducers to update the state.\n const updatedState = this.applyReducers(nextAction);\n\n // Execute effects for the action.\n const effects = this.effectsPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${effects.length} effects found to process the action ${nextAction.type}`, effects);\n effects.forEach((effect) => {\n if (effect.isFunc === true) {\n runInInjectionContext(this.injector, () => this.runEffect(effect, updatedState, nextAction));\n } else {\n this.runEffect(effect, updatedState, nextAction);\n }\n });\n } catch (error) {\n this.logger.error(`Error when processing action ${nextAction.type}`, {\n error,\n action: nextAction\n });\n } finally {\n this.logger.information(`[processNextAction] action '${nextAction.type} processed.`, nextAction);\n\n // Process the next action asynchronously.\n Promise.resolve().then(() => this.processNextAction());\n }\n }\n\n /**\n * Applies reducers to the current state based on the dispatched action.\n * Updates the state if there are changes and sets the processed action signal.\n *\n * @param nextAction - The action being processed.\n * @returns The updated state after applying reducers.\n */\n private applyReducers(nextAction: Action): State {\n try {\n const reducers = this.reducersPerActionType.get(nextAction.type) ?? [];\n this.logger.debug(`[Store] ${reducers.length} reducers found to process the action ${nextAction.type}`, reducers);\n const currentState = this._state$.getValue();\n const updatedState = reducers.reduce((p, c) => c.updateState(p, nextAction), currentState);\n\n if (updatedState !== currentState) {\n this._state$.next(updatedState);\n }\n\n return updatedState;\n } finally {\n this._processedAction.set(nextAction); // Update the processed action signal.\n }\n }\n\n /**\n * Executes an effect for a given action.\n * Handles any errors that occur during effect execution.\n *\n * @param effect - The effect to execute.\n * @param updatedState - The updated state after reducers have been applied.\n * @param nextAction - The action being processed.\n */\n private runEffect(effect: Effect, updatedState: State, nextAction: Action): void {\n try {\n effect.processAction(this, updatedState, nextAction);\n } catch (error) {\n this.logger.error(`Unable to process action ${nextAction.type} by effect ${effect}`, {\n error,\n action: nextAction,\n processor: effect\n });\n }\n }\n\n /**\n * Initializes reducers or effects and maps them to their corresponding action types.\n *\n * @param processors - The array of reducers or effects to initialize.\n * @param processorMap - The map to store processors by action type.\n * @param getProcessedActions - A function to retrieve the action types processed by a processor.\n */\n private initializeProcessors<T>(\n processors: T[] | undefined,\n processorMap: Map<string, T[]>,\n getProcessedActions: (processor: T) => string[]\n ): void {\n (processors ?? []).forEach((processor) => {\n this.logger.information('[Store] ------> initialization of ', processor);\n getProcessedActions(processor).forEach((actionType) => {\n const storedProcessors = processorMap.get(actionType) ?? [];\n if (storedProcessors.length === 0) {\n processorMap.set(actionType, storedProcessors);\n }\n storedProcessors.push(processor);\n });\n });\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface FeatureStateSpecification {\n readonly featureStateKey: string;\n readonly initialState: object;\n}\n\nexport const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<FeatureStateSpecification>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n","export enum NgssmStoreActionType {\n registerFeatureState = '[NgssmStoreActionType] registerFeatureState',\n unregisterFeatureState = '[NgssmStoreActionType] unregisterFeatureState'\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmRegisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.registerFeatureState;\n\n constructor(\n public readonly featureStateKey: string,\n public readonly initialValue: object\n ) {}\n}\n","import { Action } from '../action';\nimport { NgssmStoreActionType } from './ngssm-store-action-type';\n\nexport class NgssmUnregisterFeatureStateAction implements Action {\n public readonly type: string = NgssmStoreActionType.unregisterFeatureState;\n\n constructor(public readonly featureStateKey: string) {}\n}\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction } from '../actions';\n\nconst registerFeatureState = (featureStateKey: string, initialValue: object) => {\n return () => {\n inject(Store).dispatchAction(new NgssmRegisterFeatureStateAction(featureStateKey, initialValue));\n };\n};\n\nexport const provideNgssmFeatureState = (featureStateKey: string, initialValue: object): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(registerFeatureState(featureStateKey, initialValue))]);\n};\n","import { Directive, Inject, OnDestroy } from '@angular/core';\n\nimport { Store } from '../store';\nimport { NgssmRegisterFeatureStateAction, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { FeatureStateSpecification, NGSSM_COMPONENT_WITH_FEATURE_STATE } from './feature-state-specification';\n\n// export interface ComponentWithFeatureState {\n// featureStateKey: string;\n// initialValue: object;\n// }\n\n// export const NGSSM_COMPONENT_WITH_FEATURE_STATE = new InjectionToken<ComponentWithFeatureState>('NGSSM_COMPONENT_WITH_FEATURE_STATE');\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[provideNgssmFeatureState]',\n standalone: true\n})\nexport class ProvideNgssmFeatureStateDirective implements OnDestroy {\n constructor(\n @Inject(NGSSM_COMPONENT_WITH_FEATURE_STATE) private component: FeatureStateSpecification,\n private store: Store\n ) {\n this.store.dispatchAction(new NgssmRegisterFeatureStateAction(this.component.featureStateKey, this.component.initialState));\n }\n\n public ngOnDestroy(): void {\n this.store.dispatchAction(new NgssmUnregisterFeatureStateAction(this.component.featureStateKey));\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport update from 'immutability-helper';\n\nimport { Reducer } from '../reducer';\nimport { NgssmRegisterFeatureStateAction, NgssmStoreActionType, NgssmUnregisterFeatureStateAction } from '../actions';\nimport { State } from '../state';\nimport { Action } from '../action';\n\n@Injectable()\nexport class FeatureStateReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmStoreActionType.registerFeatureState, NgssmStoreActionType.unregisterFeatureState];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmStoreActionType.registerFeatureState: {\n const registerFeatureStateAction = action as NgssmRegisterFeatureStateAction;\n return update(state, {\n [registerFeatureStateAction.featureStateKey]: { $set: registerFeatureStateAction.initialValue }\n });\n }\n\n case NgssmStoreActionType.unregisterFeatureState: {\n const unregisterFeatureStateAction = action as NgssmUnregisterFeatureStateAction;\n return update(state, {\n $unset: [unregisterFeatureStateAction.featureStateKey]\n });\n }\n }\n\n return state;\n }\n}\n","import { Directive, OnDestroy } from '@angular/core';\nimport { map, Observable, Subject, distinctUntilChanged, takeUntil } from 'rxjs';\n\nimport { Action } from './action';\nimport { State } from './state';\nimport { Store } from './store';\n\n@Directive({\n})\nexport class NgSsmComponent implements OnDestroy {\n private readonly _unsubscribeAll$ = new Subject<void>();\n\n constructor(protected store: Store) {}\n\n protected get unsubscribeAll$(): Observable<void> {\n return this._unsubscribeAll$.asObservable();\n }\n\n public ngOnDestroy(): void {\n this._unsubscribeAll$.next();\n this._unsubscribeAll$.complete();\n }\n\n public watch<T>(selector: (state: State) => T): Observable<T> {\n return this.store.state$.pipe(\n map((state) => selector(state)),\n distinctUntilChanged(),\n takeUntil(this.unsubscribeAll$)\n );\n }\n\n public dispatchAction(action: Action): void {\n this.store.dispatchAction(action);\n }\n\n public dispatchActionType(actionType: string): void {\n this.store.dispatchActionType(actionType);\n }\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport { provideReducers } from './reducer';\nimport { ActionDispatcher } from './action-dispatcher';\nimport { FeatureStateReducer } from './feature-state';\nimport { Store } from './store';\n\nexport const ACTION_DISPATCHER = new InjectionToken<ActionDispatcher>('ACTION_DISPATCHER');\n\nexport const provideNgssmStore = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(FeatureStateReducer), { provide: ACTION_DISPATCHER, useExisting: Store }]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { State } from './state';\nimport { Store } from './store';\n\nexport const createSignal = <T = unknown>(selector: (state: State) => T): Signal<T> => {\n const store = inject(Store);\n return computed(() => selector(store.state()));\n};\n","/*\n * Public API Surface of ngssm-store\n */\n\nexport * from './lib/store';\nexport * from './lib/state';\nexport * from './lib/action';\nexport * from './lib/reducer';\nexport * from './lib/effect';\nexport * from './lib/feature-state';\nexport * from './lib/ngssm-component';\nexport * from './lib/state-initializer';\nexport * from './lib/logging';\nexport * from './lib/actions';\nexport * from './lib/provide-ngssm-store';\nexport * from './lib/signal-helpers';\nexport * from './lib/action-dispatcher';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.Logger","i1.Store"],"mappings":";;;;;MAUa,aAAa,GAAG,IAAI,cAAc,CAAU,eAAe;AAE3D,MAAA,cAAc,GAAG,CAAC,OAAsB,KAA0B;AAC7E,IAAA,OAAO,wBAAwB,CAAC,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;AAEG;;ACFH;;AAEG;;;;"}
package/lib/store.d.ts CHANGED
@@ -10,6 +10,22 @@ import { Logger } from './logging';
10
10
  import { ActionDispatcher } from './action-dispatcher';
11
11
  import * as i0 from "@angular/core";
12
12
  export declare const NgSsmFeatureState: (specification: FeatureStateSpecification) => (target: object) => void;
13
+ /**
14
+ * The `Store` class is a centralized state management system for Angular applications.
15
+ * It manages the application state, processes actions using reducers, and handles side effects using effects.
16
+ * The class integrates both RxJS (`BehaviorSubject`) and Angular signals for reactive state management.
17
+ *
18
+ * ### Features:
19
+ * - Centralized state management with support for reducers and effects.
20
+ * - Reactive state updates using both RxJS and Angular signals.
21
+ * - Modular initialization of feature states, reducers, and effects.
22
+ * - Sequential action processing with an action queue.
23
+ * - Logging for debugging and monitoring state changes and action processing.
24
+ *
25
+ * ### Usage:
26
+ * - Dispatch actions using `dispatchAction` or `dispatchActionType`.
27
+ * - Subscribe to state updates using `state$` (RxJS) or `state` (Angular signal).
28
+ */
13
29
  export declare class Store implements ActionDispatcher {
14
30
  private logger;
15
31
  private injector;
@@ -18,13 +34,78 @@ export declare class Store implements ActionDispatcher {
18
34
  private readonly reducersPerActionType;
19
35
  private readonly effectsPerActionType;
20
36
  private readonly _stateSignal;
37
+ private readonly _processedAction;
38
+ /**
39
+ * Initializes the `Store` with reducers, effects, and state initializers.
40
+ * Also sets up the initial state and registers reducers and effects.
41
+ *
42
+ * @param logger - Logger service for debugging and monitoring.
43
+ * @param reducers - Array of reducers to process state updates.
44
+ * @param effects - Array of effects to handle side effects.
45
+ * @param initializers - Array of state initializers to set up the initial state.
46
+ * @param injector - Angular's `EnvironmentInjector` for running effects in the correct context.
47
+ */
21
48
  constructor(logger: Logger, reducers: Reducer[], effects: Effect[], initializers: StateInitializer[], injector: EnvironmentInjector);
49
+ /**
50
+ * Returns the current state as an RxJS observable.
51
+ * Useful for subscribing to state changes in a reactive manner.
52
+ */
22
53
  get state$(): Observable<State>;
54
+ /**
55
+ * Returns the most recently action processed by reducers as an Angular signal.
56
+ * Useful for accessing the last processed action in a reactive manner.
57
+ * This signal is updated before processing the effects.
58
+ */
59
+ get processedAction(): Signal<Action>;
60
+ /**
61
+ * Returns the current state as an Angular signal.
62
+ * Useful for signal-based reactivity in Angular components.
63
+ */
23
64
  get state(): Signal<State>;
65
+ /**
66
+ * Dispatches an action to the store.
67
+ * The action is added to the action queue and processed sequentially.
68
+ *
69
+ * @param action - The action to dispatch.
70
+ */
24
71
  dispatchAction(action: Action): void;
72
+ /**
73
+ * Dispatches an action by its type.
74
+ * This is a shorthand for dispatching actions without additional payload.
75
+ *
76
+ * @param type - The type of the action to dispatch.
77
+ */
25
78
  dispatchActionType(type: string): void;
79
+ /**
80
+ * Processes the next action in the action queue.
81
+ * Applies reducers to update the state and executes effects for side effects.
82
+ */
26
83
  private processNextAction;
84
+ /**
85
+ * Applies reducers to the current state based on the dispatched action.
86
+ * Updates the state if there are changes and sets the processed action signal.
87
+ *
88
+ * @param nextAction - The action being processed.
89
+ * @returns The updated state after applying reducers.
90
+ */
91
+ private applyReducers;
92
+ /**
93
+ * Executes an effect for a given action.
94
+ * Handles any errors that occur during effect execution.
95
+ *
96
+ * @param effect - The effect to execute.
97
+ * @param updatedState - The updated state after reducers have been applied.
98
+ * @param nextAction - The action being processed.
99
+ */
27
100
  private runEffect;
101
+ /**
102
+ * Initializes reducers or effects and maps them to their corresponding action types.
103
+ *
104
+ * @param processors - The array of reducers or effects to initialize.
105
+ * @param processorMap - The map to store processors by action type.
106
+ * @param getProcessedActions - A function to retrieve the action types processed by a processor.
107
+ */
108
+ private initializeProcessors;
28
109
  static ɵfac: i0.ɵɵFactoryDeclaration<Store, [null, { optional: true; }, { optional: true; }, { optional: true; }, null]>;
29
110
  static ɵprov: i0.ɵɵInjectableDeclaration<Store>;
30
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngssm-store",
3
- "version": "19.2.1",
3
+ "version": "19.2.2",
4
4
  "description": "NgSsm - Simple state management implementation.",
5
5
  "author": "Lion Marc",
6
6
  "license": "MIT",
@@ -31,10 +31,6 @@
31
31
  "types": "./caching/index.d.ts",
32
32
  "default": "./fesm2022/ngssm-store-caching.mjs"
33
33
  },
34
- "./smusdi": {
35
- "types": "./smusdi/index.d.ts",
36
- "default": "./fesm2022/ngssm-store-smusdi.mjs"
37
- },
38
34
  "./testing": {
39
35
  "types": "./testing/index.d.ts",
40
36
  "default": "./fesm2022/ngssm-store-testing.mjs"
@@ -1,8 +0,0 @@
1
- const serviceInfoKey = 'service-info';
2
-
3
- /**
4
- * Generated bundle index. Do not edit.
5
- */
6
-
7
- export { serviceInfoKey };
8
- //# sourceMappingURL=ngssm-store-smusdi.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngssm-store-smusdi.mjs","sources":["../../../projects/ngssm-store/smusdi/src/model/service-info.ts","../../../projects/ngssm-store/smusdi/ngssm-store-smusdi.ts"],"sourcesContent":["import { OauthInfo } from './oauth-info';\n\nexport const serviceInfoKey = 'service-info';\n\nexport interface ProvidedCustomElements {\n script: string;\n customElements: string[];\n}\n\nexport interface ServiceInfo {\n serviceName: string;\n serviceVersion: string;\n environment: string;\n oauth?: OauthInfo;\n customElements?: ProvidedCustomElements;\n serviceUrl?: string;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":"AAEO,MAAM,cAAc,GAAG;;ACF9B;;AAEG;;;;"}
package/smusdi/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="ngssm-store/smusdi" />
5
- export * from './public_api';
@@ -1 +0,0 @@
1
- export * from './src/public-api';
@@ -1,3 +0,0 @@
1
- export * from './search-query-result';
2
- export * from './oauth-info';
3
- export * from './service-info';
@@ -1,3 +0,0 @@
1
- export interface OauthInfo {
2
- authority: string;
3
- }
@@ -1,5 +0,0 @@
1
- export interface SearchQueryResult<TData> {
2
- maxResults: number;
3
- totalResults: number;
4
- results: TData[];
5
- }
@@ -1,14 +0,0 @@
1
- import { OauthInfo } from './oauth-info';
2
- export declare const serviceInfoKey = "service-info";
3
- export interface ProvidedCustomElements {
4
- script: string;
5
- customElements: string[];
6
- }
7
- export interface ServiceInfo {
8
- serviceName: string;
9
- serviceVersion: string;
10
- environment: string;
11
- oauth?: OauthInfo;
12
- customElements?: ProvidedCustomElements;
13
- serviceUrl?: string;
14
- }
@@ -1 +0,0 @@
1
- export * from './model';