@angular-architects/ngrx-toolkit 20.4.0 → 20.4.1
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.
|
@@ -342,7 +342,7 @@ Enable automatic indexing via withDevTools('${storeName}', { indexNames: true })
|
|
|
342
342
|
}, {});
|
|
343
343
|
this.#currentState = Object.entries(this.#currentState).reduce((newState, [storeName, state]) => {
|
|
344
344
|
if (storeName !== name) {
|
|
345
|
-
newState[
|
|
345
|
+
newState[storeName] = state;
|
|
346
346
|
}
|
|
347
347
|
return newState;
|
|
348
348
|
}, {});
|
|
@@ -350,18 +350,31 @@ Enable automatic indexing via withDevTools('${storeName}', { indexNames: true })
|
|
|
350
350
|
tracker.removeStore(id);
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Renames a store identified by its internal id. If the store has already
|
|
355
|
+
* been removed (e.g. due to component destruction), this is a no-op.
|
|
356
|
+
*/
|
|
357
|
+
renameStore(id, newName) {
|
|
358
|
+
const storeEntry = this.#stores[id];
|
|
359
|
+
if (!storeEntry) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const oldName = storeEntry.name;
|
|
363
|
+
if (oldName === newName) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const otherStoreNames = Object.entries(this.#stores)
|
|
367
|
+
.filter(([entryId]) => entryId !== id)
|
|
368
|
+
.map(([, s]) => s.name);
|
|
369
|
+
if (otherStoreNames.includes(newName)) {
|
|
357
370
|
throw new Error(`NgRx Toolkit/DevTools: cannot rename from ${oldName} to ${newName}. ${newName} is already assigned to another SignalStore instance.`);
|
|
358
371
|
}
|
|
359
|
-
this.#stores = Object.entries(this.#stores).reduce((newStore, [
|
|
360
|
-
if (
|
|
361
|
-
newStore[
|
|
372
|
+
this.#stores = Object.entries(this.#stores).reduce((newStore, [entryId, value]) => {
|
|
373
|
+
if (entryId === id) {
|
|
374
|
+
newStore[entryId] = { ...value, name: newName };
|
|
362
375
|
}
|
|
363
376
|
else {
|
|
364
|
-
newStore[
|
|
377
|
+
newStore[entryId] = value;
|
|
365
378
|
}
|
|
366
379
|
return newStore;
|
|
367
380
|
}, {});
|
|
@@ -406,7 +419,7 @@ function withDevtools(name, ...features) {
|
|
|
406
419
|
// TODO: use withProps and symbols
|
|
407
420
|
return {
|
|
408
421
|
[renameDevtoolsMethodName]: (newName) => {
|
|
409
|
-
syncer.renameStore(
|
|
422
|
+
syncer.renameStore(id, newName);
|
|
410
423
|
},
|
|
411
424
|
[uniqueDevtoolsId]: () => id,
|
|
412
425
|
};
|