@ngrx/signals 20.0.1 → 21.0.0-beta.0

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.
Files changed (110) hide show
  1. package/fesm2022/ngrx-signals-entities.mjs.map +1 -1
  2. package/fesm2022/ngrx-signals-events.mjs +223 -61
  3. package/fesm2022/ngrx-signals-events.mjs.map +1 -1
  4. package/fesm2022/ngrx-signals-rxjs-interop.mjs +5 -5
  5. package/fesm2022/ngrx-signals-rxjs-interop.mjs.map +1 -1
  6. package/fesm2022/ngrx-signals.mjs +31 -25
  7. package/fesm2022/ngrx-signals.mjs.map +1 -1
  8. package/migrations/18_0_0-rc_3-protected-state/index.js +54 -23
  9. package/migrations/18_0_0-rc_3-protected-state/index.js.map +1 -1
  10. package/migrations/18_0_0-rc_3-writablestatesource/index.js +45 -12
  11. package/migrations/18_0_0-rc_3-writablestatesource/index.js.map +1 -1
  12. package/migrations/19_0_0-rc_0-props/index.js +72 -83
  13. package/migrations/19_0_0-rc_0-props/index.js.map +1 -1
  14. package/migrations/21_0_0-beta_0-rename-withEffects-to-withEventHandlers/index.js +103 -0
  15. package/migrations/21_0_0-beta_0-rename-withEffects-to-withEventHandlers/index.js.map +1 -0
  16. package/migrations/migration.json +5 -0
  17. package/package.json +8 -8
  18. package/schematics/ng-add/index.js +5 -5
  19. package/schematics/ng-add/index.js.map +1 -1
  20. package/schematics-core/index.js +1 -1
  21. package/schematics-core/index.js.map +1 -1
  22. package/schematics-core/utility/ast-utils.js +198 -240
  23. package/schematics-core/utility/ast-utils.js.map +1 -1
  24. package/schematics-core/utility/change.js +68 -85
  25. package/schematics-core/utility/change.js.map +1 -1
  26. package/schematics-core/utility/config.js +7 -7
  27. package/schematics-core/utility/config.js.map +1 -1
  28. package/schematics-core/utility/find-component.js +20 -20
  29. package/schematics-core/utility/find-component.js.map +1 -1
  30. package/schematics-core/utility/find-module.js +21 -21
  31. package/schematics-core/utility/find-module.js.map +1 -1
  32. package/schematics-core/utility/json-utilts.js +4 -26
  33. package/schematics-core/utility/json-utilts.js.map +1 -1
  34. package/schematics-core/utility/libs-version.js +1 -1
  35. package/schematics-core/utility/libs-version.js.map +1 -1
  36. package/schematics-core/utility/ngrx-utils.js +110 -141
  37. package/schematics-core/utility/ngrx-utils.js.map +1 -1
  38. package/schematics-core/utility/package.js +2 -3
  39. package/schematics-core/utility/package.js.map +1 -1
  40. package/schematics-core/utility/parse-name.js +3 -3
  41. package/schematics-core/utility/parse-name.js.map +1 -1
  42. package/schematics-core/utility/project.js +13 -13
  43. package/schematics-core/utility/project.js.map +1 -1
  44. package/schematics-core/utility/strings.js +12 -12
  45. package/schematics-core/utility/strings.js.map +1 -1
  46. package/schematics-core/utility/update.js +12 -12
  47. package/schematics-core/utility/update.js.map +1 -1
  48. package/schematics-core/utility/visitors.js +78 -180
  49. package/schematics-core/utility/visitors.js.map +1 -1
  50. package/types/ngrx-signals-entities.d.ts +324 -0
  51. package/types/ngrx-signals-events.d.ts +360 -0
  52. package/types/ngrx-signals-rxjs-interop.d.ts +15 -0
  53. package/{testing/src/unprotected.d.ts → types/ngrx-signals-testing.d.ts} +5 -3
  54. package/types/ngrx-signals.d.ts +332 -0
  55. package/entities/index.d.ts +0 -1
  56. package/entities/src/entity-config.d.ts +0 -17
  57. package/entities/src/helpers.d.ts +0 -25
  58. package/entities/src/index.d.ts +0 -18
  59. package/entities/src/models.d.ts +0 -24
  60. package/entities/src/updaters/add-entities.d.ts +0 -17
  61. package/entities/src/updaters/add-entity.d.ts +0 -17
  62. package/entities/src/updaters/prepend-entities.d.ts +0 -17
  63. package/entities/src/updaters/prepend-entity.d.ts +0 -17
  64. package/entities/src/updaters/remove-all-entities.d.ts +0 -6
  65. package/entities/src/updaters/remove-entities.d.ts +0 -10
  66. package/entities/src/updaters/remove-entity.d.ts +0 -6
  67. package/entities/src/updaters/set-all-entities.d.ts +0 -17
  68. package/entities/src/updaters/set-entities.d.ts +0 -17
  69. package/entities/src/updaters/set-entity.d.ts +0 -17
  70. package/entities/src/updaters/update-all-entities.d.ts +0 -17
  71. package/entities/src/updaters/update-entities.d.ts +0 -56
  72. package/entities/src/updaters/update-entity.d.ts +0 -29
  73. package/entities/src/updaters/upsert-entities.d.ts +0 -17
  74. package/entities/src/updaters/upsert-entity.d.ts +0 -17
  75. package/entities/src/with-entities.d.ts +0 -22
  76. package/events/index.d.ts +0 -1
  77. package/events/src/case-reducer.d.ts +0 -20
  78. package/events/src/dispatcher.d.ts +0 -33
  79. package/events/src/event-creator-group.d.ts +0 -33
  80. package/events/src/event-creator.d.ts +0 -9
  81. package/events/src/event-instance.d.ts +0 -8
  82. package/events/src/events-service.d.ts +0 -47
  83. package/events/src/index.d.ts +0 -9
  84. package/events/src/inject-dispatch.d.ts +0 -46
  85. package/events/src/with-effects.d.ts +0 -28
  86. package/events/src/with-reducer.d.ts +0 -30
  87. package/index.d.ts +0 -1
  88. package/rxjs-interop/index.d.ts +0 -1
  89. package/rxjs-interop/src/index.d.ts +0 -1
  90. package/rxjs-interop/src/rx-method.d.ts +0 -12
  91. package/src/deep-computed.d.ts +0 -2
  92. package/src/deep-signal.d.ts +0 -6
  93. package/src/index.d.ts +0 -16
  94. package/src/signal-method.d.ts +0 -7
  95. package/src/signal-state.d.ts +0 -4
  96. package/src/signal-store-assertions.d.ts +0 -2
  97. package/src/signal-store-feature.d.ts +0 -29
  98. package/src/signal-store-models.d.ts +0 -30
  99. package/src/signal-store.d.ts +0 -142
  100. package/src/state-source.d.ts +0 -23
  101. package/src/ts-helpers.d.ts +0 -11
  102. package/src/with-computed.d.ts +0 -12
  103. package/src/with-feature.d.ts +0 -26
  104. package/src/with-hooks.d.ts +0 -14
  105. package/src/with-linked-state.d.ts +0 -52
  106. package/src/with-methods.d.ts +0 -8
  107. package/src/with-props.d.ts +0 -8
  108. package/src/with-state.d.ts +0 -11
  109. package/testing/index.d.ts +0 -1
  110. package/testing/src/index.d.ts +0 -1
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function prependEntity<Entity extends {
4
- id: EntityId;
5
- }>(entity: Entity): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function prependEntity<Entity, Collection extends string>(entity: Entity, config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function prependEntity<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entity: Entity, config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function prependEntity<Entity>(entity: Entity, config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,6 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityState, NamedEntityState } from '../models';
3
- export declare function removeAllEntities(): PartialStateUpdater<EntityState<any>>;
4
- export declare function removeAllEntities<Collection extends string>(config: {
5
- collection: Collection;
6
- }): PartialStateUpdater<NamedEntityState<any, Collection>>;
@@ -1,10 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityPredicate, EntityState, NamedEntityState } from '../models';
3
- export declare function removeEntities(ids: EntityId[]): PartialStateUpdater<EntityState<any>>;
4
- export declare function removeEntities<Entity>(predicate: EntityPredicate<Entity>): PartialStateUpdater<EntityState<Entity>>;
5
- export declare function removeEntities<Collection extends string>(ids: EntityId[], config: {
6
- collection: Collection;
7
- }): PartialStateUpdater<NamedEntityState<any, Collection>>;
8
- export declare function removeEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E, Collection> ? E : never>(predicate: EntityPredicate<Entity>, config: {
9
- collection: Collection;
10
- }): PartialStateUpdater<State>;
@@ -1,6 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState } from '../models';
3
- export declare function removeEntity(id: EntityId): PartialStateUpdater<EntityState<any>>;
4
- export declare function removeEntity<Collection extends string>(id: EntityId, config: {
5
- collection: Collection;
6
- }): PartialStateUpdater<NamedEntityState<any, Collection>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function setAllEntities<Entity extends {
4
- id: EntityId;
5
- }>(entities: Entity[]): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function setAllEntities<Entity, Collection extends string>(entities: Entity[], config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function setAllEntities<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entities: Entity[], config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function setAllEntities<Entity>(entities: Entity[], config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function setEntities<Entity extends {
4
- id: EntityId;
5
- }>(entities: Entity[]): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function setEntities<Entity, Collection extends string>(entities: Entity[], config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function setEntities<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entities: Entity[], config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function setEntities<Entity>(entities: Entity[], config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function setEntity<Entity extends {
4
- id: EntityId;
5
- }>(entity: Entity): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function setEntity<Entity, Collection extends string>(entity: Entity, config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function setEntity<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entity: Entity, config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function setEntity<Entity>(entity: Entity, config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityChanges, EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function updateAllEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E, Collection> ? E : never>(changes: EntityChanges<NoInfer<Entity>>, config: {
4
- collection: Collection;
5
- selectId: SelectEntityId<NoInfer<Entity>>;
6
- }): PartialStateUpdater<State>;
7
- export declare function updateAllEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E extends {
8
- id: EntityId;
9
- }, Collection> ? E : never>(changes: EntityChanges<NoInfer<Entity>>, config: {
10
- collection: Collection;
11
- }): PartialStateUpdater<State>;
12
- export declare function updateAllEntities<Entity>(changes: EntityChanges<NoInfer<Entity>>, config: {
13
- selectId: SelectEntityId<NoInfer<Entity>>;
14
- }): PartialStateUpdater<EntityState<Entity>>;
15
- export declare function updateAllEntities<Entity extends {
16
- id: EntityId;
17
- }>(changes: EntityChanges<NoInfer<Entity>>): PartialStateUpdater<EntityState<Entity>>;
@@ -1,56 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityChanges, EntityId, EntityPredicate, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function updateEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E, Collection> ? E : never>(update: {
4
- ids: EntityId[];
5
- changes: EntityChanges<NoInfer<Entity>>;
6
- }, config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<State>;
10
- export declare function updateEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E, Collection> ? E : never>(update: {
11
- predicate: EntityPredicate<Entity>;
12
- changes: EntityChanges<NoInfer<Entity>>;
13
- }, config: {
14
- collection: Collection;
15
- selectId: SelectEntityId<NoInfer<Entity>>;
16
- }): PartialStateUpdater<State>;
17
- export declare function updateEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E extends {
18
- id: EntityId;
19
- }, Collection> ? E : never>(update: {
20
- ids: EntityId[];
21
- changes: EntityChanges<NoInfer<Entity>>;
22
- }, config: {
23
- collection: Collection;
24
- }): PartialStateUpdater<State>;
25
- export declare function updateEntities<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E extends {
26
- id: EntityId;
27
- }, Collection> ? E : never>(update: {
28
- predicate: EntityPredicate<Entity>;
29
- changes: EntityChanges<NoInfer<Entity>>;
30
- }, config: {
31
- collection: Collection;
32
- }): PartialStateUpdater<State>;
33
- export declare function updateEntities<Entity>(update: {
34
- ids: EntityId[];
35
- changes: EntityChanges<NoInfer<Entity>>;
36
- }, config: {
37
- selectId: SelectEntityId<NoInfer<Entity>>;
38
- }): PartialStateUpdater<EntityState<Entity>>;
39
- export declare function updateEntities<Entity>(update: {
40
- predicate: EntityPredicate<Entity>;
41
- changes: EntityChanges<NoInfer<Entity>>;
42
- }, config: {
43
- selectId: SelectEntityId<NoInfer<Entity>>;
44
- }): PartialStateUpdater<EntityState<Entity>>;
45
- export declare function updateEntities<Entity extends {
46
- id: EntityId;
47
- }>(update: {
48
- ids: EntityId[];
49
- changes: EntityChanges<NoInfer<Entity>>;
50
- }): PartialStateUpdater<EntityState<Entity>>;
51
- export declare function updateEntities<Entity extends {
52
- id: EntityId;
53
- }>(update: {
54
- predicate: EntityPredicate<Entity>;
55
- changes: EntityChanges<NoInfer<Entity>>;
56
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,29 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityChanges, EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function updateEntity<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E, Collection> ? E : never>(update: {
4
- id: EntityId;
5
- changes: EntityChanges<NoInfer<Entity>>;
6
- }, config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<State>;
10
- export declare function updateEntity<Collection extends string, State extends NamedEntityState<any, Collection>, Entity = State extends NamedEntityState<infer E extends {
11
- id: EntityId;
12
- }, Collection> ? E : never>(update: {
13
- id: EntityId;
14
- changes: EntityChanges<NoInfer<Entity>>;
15
- }, config: {
16
- collection: Collection;
17
- }): PartialStateUpdater<State>;
18
- export declare function updateEntity<Entity>(update: {
19
- id: EntityId;
20
- changes: EntityChanges<NoInfer<Entity>>;
21
- }, config: {
22
- selectId: SelectEntityId<NoInfer<Entity>>;
23
- }): PartialStateUpdater<EntityState<Entity>>;
24
- export declare function updateEntity<Entity extends {
25
- id: EntityId;
26
- }>(update: {
27
- id: EntityId;
28
- changes: EntityChanges<NoInfer<Entity>>;
29
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function upsertEntities<Entity extends {
4
- id: EntityId;
5
- }>(entities: Entity[]): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function upsertEntities<Entity, Collection extends string>(entities: Entity[], config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function upsertEntities<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entities: Entity[], config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function upsertEntities<Entity>(entities: Entity[], config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,17 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
3
- export declare function upsertEntity<Entity extends {
4
- id: EntityId;
5
- }>(entity: Entity): PartialStateUpdater<EntityState<Entity>>;
6
- export declare function upsertEntity<Entity, Collection extends string>(entity: Entity, config: {
7
- collection: Collection;
8
- selectId: SelectEntityId<NoInfer<Entity>>;
9
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
10
- export declare function upsertEntity<Entity extends {
11
- id: EntityId;
12
- }, Collection extends string>(entity: Entity, config: {
13
- collection: Collection;
14
- }): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
15
- export declare function upsertEntity<Entity>(entity: Entity, config: {
16
- selectId: SelectEntityId<NoInfer<Entity>>;
17
- }): PartialStateUpdater<EntityState<Entity>>;
@@ -1,22 +0,0 @@
1
- import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
2
- import { EntityProps, EntityState, NamedEntityProps, NamedEntityState } from './models';
3
- export declare function withEntities<Entity>(): SignalStoreFeature<EmptyFeatureResult, {
4
- state: EntityState<Entity>;
5
- props: EntityProps<Entity>;
6
- methods: {};
7
- }>;
8
- export declare function withEntities<Entity, Collection extends string>(config: {
9
- entity: Entity;
10
- collection: Collection;
11
- }): SignalStoreFeature<EmptyFeatureResult, {
12
- state: NamedEntityState<Entity, Collection>;
13
- props: NamedEntityProps<Entity, Collection>;
14
- methods: {};
15
- }>;
16
- export declare function withEntities<Entity>(config: {
17
- entity: Entity;
18
- }): SignalStoreFeature<EmptyFeatureResult, {
19
- state: EntityState<Entity>;
20
- props: EntityProps<Entity>;
21
- methods: {};
22
- }>;
package/events/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src/index';
@@ -1,20 +0,0 @@
1
- import { PartialStateUpdater } from '@ngrx/signals';
2
- import { EventCreator } from './event-creator';
3
- export type CaseReducerResult<State extends object, EventCreators extends EventCreator<string, any>[]> = {
4
- reducer: CaseReducer<State, EventCreators>;
5
- events: EventCreators;
6
- };
7
- type CaseReducer<State extends object, EventCreators extends EventCreator<string, any>[]> = (event: {
8
- [K in keyof EventCreators]: ReturnType<EventCreators[K]>;
9
- }[number], state: State) => Partial<State> | PartialStateUpdater<State> | Array<Partial<State> | PartialStateUpdater<State>>;
10
- /**
11
- * @experimental
12
- * @description
13
- *
14
- * Creates a case reducer that can be used with the `withReducer` feature.
15
- */
16
- export declare function on<State extends object, EventCreators extends EventCreator<string, any>[]>(...args: [
17
- ...events: [...EventCreators],
18
- reducer: CaseReducer<NoInfer<State>, NoInfer<EventCreators>>
19
- ]): CaseReducerResult<State, EventCreators>;
20
- export {};
@@ -1,33 +0,0 @@
1
- import { EventInstance } from './event-instance';
2
- import { Events, ReducerEvents } from './events-service';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * @experimental
6
- * @description
7
- *
8
- * Globally provided service for dispatching events.
9
- *
10
- * @usageNotes
11
- *
12
- * ```ts
13
- * import { Dispatcher, event } from '@ngrx/signals/events';
14
- *
15
- * const increment = event('[Counter Page] Increment');
16
- *
17
- * \@Component({ \/* ... *\/ })
18
- * class Counter {
19
- * readonly #dispatcher = inject(Dispatcher);
20
- *
21
- * increment(): void {
22
- * this.#dispatcher.dispatch(increment());
23
- * }
24
- * }
25
- * ```
26
- */
27
- export declare class Dispatcher {
28
- protected readonly reducerEvents: ReducerEvents;
29
- protected readonly events: Events;
30
- dispatch(event: EventInstance<string, unknown>): void;
31
- static ɵfac: i0.ɵɵFactoryDeclaration<Dispatcher, never>;
32
- static ɵprov: i0.ɵɵInjectableDeclaration<Dispatcher>;
33
- }
@@ -1,33 +0,0 @@
1
- import { Prettify } from '@ngrx/signals';
2
- import { EventCreator } from './event-creator';
3
- type EventType<Source extends string, EventName extends string> = `[${Source}] ${EventName}`;
4
- type EventCreatorGroup<Source extends string, Events extends Record<string, any>> = {
5
- [EventName in keyof Events]: EventName extends string ? EventCreator<EventType<Source, EventName>, Events[EventName]> : never;
6
- };
7
- /**
8
- * @experimental
9
- * @description
10
- *
11
- * Creates a group of event creators.
12
- *
13
- * @usageNotes
14
- *
15
- * ```ts
16
- * import { type } from '@ngrx/signals';
17
- * import { eventGroup } from '@ngrx/signals/events';
18
- *
19
- * const counterPageEvents = eventGroup({
20
- * source: 'Counter Page',
21
- * events: {
22
- * increment: type<void>(),
23
- * decrement: type<void>(),
24
- * set: type<number>(),
25
- * },
26
- * });
27
- * ```
28
- */
29
- export declare function eventGroup<Source extends string, Events extends Record<string, unknown>>(config: {
30
- source: Source;
31
- events: Events;
32
- }): Prettify<EventCreatorGroup<Source, Events>>;
33
- export {};
@@ -1,9 +0,0 @@
1
- import { EventInstance } from './event-instance';
2
- /**
3
- * @experimental
4
- */
5
- export type EventCreator<Type extends string, Payload> = ((payload: Payload) => EventInstance<Type, Payload>) & {
6
- type: Type;
7
- };
8
- export declare function event<Type extends string>(type: Type): EventCreator<Type, void>;
9
- export declare function event<Type extends string, Payload>(type: Type, payload: Payload): EventCreator<Type, Payload>;
@@ -1,8 +0,0 @@
1
- /**
2
- * @experimental
3
- */
4
- export type EventInstance<Type extends string, Payload> = {
5
- type: Type;
6
- payload: Payload;
7
- };
8
- export declare function isEventInstance(value: unknown): value is EventInstance<string, unknown>;
@@ -1,47 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { EventInstance } from './event-instance';
3
- import { EventCreator } from './event-creator';
4
- import * as i0 from "@angular/core";
5
- export declare const EVENTS: unique symbol;
6
- export declare const SOURCE_TYPE: unique symbol;
7
- declare abstract class BaseEvents {
8
- on(): Observable<EventInstance<string, unknown>>;
9
- on<EventCreators extends EventCreator<string, any>[]>(...events: [...EventCreators]): Observable<{
10
- [K in keyof EventCreators]: ReturnType<EventCreators[K]>;
11
- }[number]>;
12
- }
13
- /**
14
- * @experimental
15
- * @description
16
- *
17
- * Globally provided service for listening to dispatched events.
18
- *
19
- * @usageNotes
20
- *
21
- * ```ts
22
- * import { event, Events } from '@ngrx/signals/events';
23
- *
24
- * const increment = event('[Counter Page] Increment');
25
- *
26
- * \@Component({ \/* ... *\/ })
27
- * class Counter {
28
- * readonly #events = inject(Events);
29
- *
30
- * constructor() {
31
- * this.#events
32
- * .on(increment)
33
- * .pipe(takeUntilDestroyed())
34
- * .subscribe(() => \/* handle increment event *\/);
35
- * }
36
- * }
37
- * ```
38
- */
39
- export declare class Events extends BaseEvents {
40
- static ɵfac: i0.ɵɵFactoryDeclaration<Events, never>;
41
- static ɵprov: i0.ɵɵInjectableDeclaration<Events>;
42
- }
43
- export declare class ReducerEvents extends BaseEvents {
44
- static ɵfac: i0.ɵɵFactoryDeclaration<ReducerEvents, never>;
45
- static ɵprov: i0.ɵɵInjectableDeclaration<ReducerEvents>;
46
- }
47
- export {};
@@ -1,9 +0,0 @@
1
- export { on } from './case-reducer';
2
- export { Dispatcher } from './dispatcher';
3
- export { event, EventCreator } from './event-creator';
4
- export { eventGroup } from './event-creator-group';
5
- export { EventInstance } from './event-instance';
6
- export { Events } from './events-service';
7
- export { injectDispatch } from './inject-dispatch';
8
- export { withEffects } from './with-effects';
9
- export { withReducer } from './with-reducer';
@@ -1,46 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import { Prettify } from '@ngrx/signals';
3
- import { EventCreator } from './event-creator';
4
- type InjectDispatchResult<EventGroup extends Record<string, EventCreator<string, any>>> = {
5
- [EventName in keyof EventGroup]: Parameters<EventGroup[EventName]> extends [
6
- infer Payload
7
- ] ? (payload: Payload) => void : () => void;
8
- };
9
- /**
10
- * @experimental
11
- * @description
12
- *
13
- * Creates self-dispatching events for a given event group.
14
- *
15
- * @usageNotes
16
- *
17
- * ```ts
18
- * import { type } from '@ngrx/signals';
19
- * import { eventGroup, injectDispatch } from '@ngrx/signals/events';
20
- *
21
- * const counterPageEvents = eventGroup({
22
- * source: 'Counter Page',
23
- * events: {
24
- * increment: type<void>(),
25
- * decrement: type<void>(),
26
- * },
27
- * });
28
- *
29
- * \@Component({ \/* ... *\/ })
30
- * class Counter {
31
- * readonly dispatch = injectDispatch(counterPageEvents);
32
- *
33
- * increment(): void {
34
- * this.dispatch.increment();
35
- * }
36
- *
37
- * decrement(): void {
38
- * this.dispatch.decrement();
39
- * }
40
- * }
41
- * ```
42
- */
43
- export declare function injectDispatch<EventGroup extends Record<string, EventCreator<string, any>>>(events: EventGroup, config?: {
44
- injector?: Injector;
45
- }): Prettify<InjectDispatchResult<EventGroup>>;
46
- export {};
@@ -1,28 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { EmptyFeatureResult, Prettify, SignalStoreFeature, SignalStoreFeatureResult, StateSignals, WritableStateSource } from '@ngrx/signals';
3
- /**
4
- * @experimental
5
- * @description
6
- *
7
- * SignalStore feature for defining side effects.
8
- *
9
- * @usageNotes
10
- *
11
- * ```ts
12
- * import { signalStore, withState } from '@ngrx/signals';
13
- * import { event, Events, withEffects } from '@ngrx/signals/events';
14
- *
15
- * const increment = event('[Counter Page] Increment');
16
- * const decrement = event('[Counter Page] Decrement');
17
- *
18
- * const CounterStore = signalStore(
19
- * withState({ count: 0 }),
20
- * withEffects(({ count }, events = inject(Events)) => ({
21
- * logCount$: events.on(increment, decrement).pipe(
22
- * tap(({ type }) => console.log(type, count())),
23
- * ),
24
- * })),
25
- * );
26
- * ```
27
- */
28
- export declare function withEffects<Input extends SignalStoreFeatureResult>(effectsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Record<string, Observable<unknown>>): SignalStoreFeature<Input, EmptyFeatureResult>;
@@ -1,30 +0,0 @@
1
- import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
2
- import { CaseReducerResult } from './case-reducer';
3
- import { EventCreator } from './event-creator';
4
- /**
5
- * @experimental
6
- * @description
7
- *
8
- * SignalStore feature for defining state changes based on dispatched events.
9
- *
10
- * @usageNotes
11
- *
12
- * ```ts
13
- * import { signalStore, type, withState } from '@ngrx/signals';
14
- * import { event, on, withReducer } from '@ngrx/signals/events';
15
- *
16
- * const set = event('[Counter Page] Set', type<number>());
17
- *
18
- * const CounterStore = signalStore(
19
- * withState({ count: 0 }),
20
- * withReducer(
21
- * on(set, ({ payload }) => ({ count: payload })),
22
- * ),
23
- * );
24
- * ```
25
- */
26
- export declare function withReducer<State extends object>(...caseReducers: CaseReducerResult<State, EventCreator<string, any>[]>[]): SignalStoreFeature<{
27
- state: State;
28
- props: {};
29
- methods: {};
30
- }, EmptyFeatureResult>;
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src/index';
@@ -1 +0,0 @@
1
- export * from './src/index';
@@ -1 +0,0 @@
1
- export { rxMethod, RxMethod } from './rx-method';
@@ -1,12 +0,0 @@
1
- import { Injector, Signal } from '@angular/core';
2
- import { Observable } from 'rxjs';
3
- type RxMethodRef = {
4
- destroy: () => void;
5
- };
6
- export type RxMethod<Input> = ((input: Input | Signal<Input> | Observable<Input>, config?: {
7
- injector?: Injector;
8
- }) => RxMethodRef) & RxMethodRef;
9
- export declare function rxMethod<Input>(generator: (source$: Observable<Input>) => Observable<unknown>, config?: {
10
- injector?: Injector;
11
- }): RxMethod<Input>;
12
- export {};
@@ -1,2 +0,0 @@
1
- import { DeepSignal } from './deep-signal';
2
- export declare function deepComputed<T extends object>(computation: () => T): DeepSignal<T>;
@@ -1,6 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { IsKnownRecord } from './ts-helpers';
3
- export type DeepSignal<T> = Signal<T> & (IsKnownRecord<T> extends true ? Readonly<{
4
- [K in keyof T]: IsKnownRecord<T[K]> extends true ? DeepSignal<T[K]> : Signal<T[K]>;
5
- }> : unknown);
6
- export declare function toDeepSignal<T>(signal: Signal<T>): DeepSignal<T>;
package/src/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- export { deepComputed } from './deep-computed';
2
- export { DeepSignal } from './deep-signal';
3
- export { signalMethod, SignalMethod } from './signal-method';
4
- export { signalState, SignalState } from './signal-state';
5
- export { signalStore } from './signal-store';
6
- export { signalStoreFeature, type } from './signal-store-feature';
7
- export { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult, StateSignals, } from './signal-store-models';
8
- export { getState, isWritableStateSource, PartialStateUpdater, patchState, StateSource, StateWatcher, watchState, WritableStateSource, } from './state-source';
9
- export { Prettify } from './ts-helpers';
10
- export { withComputed } from './with-computed';
11
- export { withFeature } from './with-feature';
12
- export { withHooks } from './with-hooks';
13
- export { withLinkedState } from './with-linked-state';
14
- export { withMethods } from './with-methods';
15
- export { withProps } from './with-props';
16
- export { withState } from './with-state';
@@ -1,7 +0,0 @@
1
- import { EffectRef, Injector, Signal } from '@angular/core';
2
- export type SignalMethod<Input> = ((input: Input | Signal<Input>, config?: {
3
- injector?: Injector;
4
- }) => EffectRef) & EffectRef;
5
- export declare function signalMethod<Input>(processingFn: (value: Input) => void, config?: {
6
- injector?: Injector;
7
- }): SignalMethod<Input>;
@@ -1,4 +0,0 @@
1
- import { DeepSignal } from './deep-signal';
2
- import { WritableStateSource } from './state-source';
3
- export type SignalState<State extends object> = DeepSignal<State> & WritableStateSource<State>;
4
- export declare function signalState<State extends object>(initialState: State): SignalState<State>;
@@ -1,2 +0,0 @@
1
- import { InnerSignalStore } from './signal-store-models';
2
- export declare function assertUniqueStoreMembers(store: InnerSignalStore, newMemberKeys: Array<string | symbol>): void;